Skip to content

Instantly share code, notes, and snippets.

@airportyh
Created December 22, 2010 21:10
Show Gist options
  • Save airportyh/752104 to your computer and use it in GitHub Desktop.
Save airportyh/752104 to your computer and use it in GitHub Desktop.
Loading Modernizr inside Tutti
Connecting...
Welcome to Tutti - interactively run Javascript on multiple browsers!
====================================================================
You can execute any Javascript in the shell below.
Connected browsers: Firefox 3.6, IE 8.0
To connect another browser, just copy-n-paste the current URL into it.
Firefox 3.6 disconnected
Firefox 3.6 joined
> if (!document.body) document.appendChild(document.createElement('body'))
Chrome 8.0 => Error: HIERARCHY_REQUEST_ERR: DOM Exception 3
Firefox 3.6 => Error: Node cannot be inserted at the specified point in the hierarchy
IE 8.0 => [object HTMLBodyElement]
> document.body
Chrome 8.0 => null
Firefox 3.6 => null
IE 8.0 => [object HTMLBodyElement]
> document.body = document.body || document.createElement('body')
Chrome 8.0 => [object HTMLBodyElement]
Firefox 3.6 => [object HTMLBodyElement]
IE 8.0 => Error: Member not found.
> document.body
Chrome 8.0 => [object HTMLBodyElement]
Firefox 3.6 => [object HTMLBodyElement]
IE 8.0 => [object HTMLBodyElement]
> var s = document.createElement('script')
Chrome 8.0 => undefined
Firefox 3.6 => undefined
IE 8.0 => undefined
> s.setAttribute('src', 'https://github.com/Modernizr/Modernizr/raw/master/modernizr.js')
Chrome 8.0 => undefined
Firefox 3.6 => undefined
IE 8.0 => undefined
> document.body.appendChild(s)
Chrome 8.0 => [object HTMLScriptElement]
Firefox 3.6 => [object HTMLScriptElement]
IE 8.0 => [object HTMLScriptElement]
> Modernizr
Chrome 8.0 => [object Object]
Firefox 3.6 => [object Object]
IE 8.0 => [object Object]
> for (var key in Modernizr) console.log(key + ':' + Modernizr[key] + ', ')
Chrome 8.0 : flexbox:true,
Chrome 8.0 : canvas:true,
Chrome 8.0 : canvastext:true,
Chrome 8.0 : webgl:false,
Chrome 8.0 : touch:false,
Chrome 8.0 : geolocation:true,
Chrome 8.0 : postmessage:true,
Chrome 8.0 : websqldatabase:true,
Chrome 8.0 : indexeddb:false,
Chrome 8.0 : hashchange:true,
Chrome 8.0 : history:true,
Chrome 8.0 : draganddrop:true,
Chrome 8.0 : websockets:true,
Chrome 8.0 : rgba:true,
Chrome 8.0 : hsla:true,
Chrome 8.0 : multiplebgs:true,
Chrome 8.0 : backgroundsize:true,
Chrome 8.0 : borderimage:true,
Chrome 8.0 : borderradius:true,
Chrome 8.0 : boxshadow:true,
Chrome 8.0 : textshadow:true,
Chrome 8.0 : opacity:true,
Chrome 8.0 : cssanimations:true,
Chrome 8.0 : csscolumns:true,
Chrome 8.0 : cssgradients:true,
Chrome 8.0 : cssreflections:true,
Chrome 8.0 : csstransforms:true,
Chrome 8.0 : csstransforms3d:false,
Chrome 8.0 : csstransitions:true,
Chrome 8.0 : fontface:true,
Chrome 8.0 : video:true,
Chrome 8.0 : audio:true,
Chrome 8.0 : localstorage:true,
Chrome 8.0 : sessionstorage:true,
Chrome 8.0 : webworkers:true,
Chrome 8.0 : applicationcache:true,
Chrome 8.0 : svg:true,
Chrome 8.0 : inlinesvg:true,
Chrome 8.0 : smil:true,
Chrome 8.0 : svgclippaths:true,
Chrome 8.0 : input:[object Object],
Chrome 8.0 : inputtypes:[object Object],
Chrome 8.0 : crosswindowmessaging:true,
Chrome 8.0 : historymanagement:true,
Chrome 8.0 : addTest:function (feature, test) { feature = feature.toLowerCase(); if (ret[ feature ]) { return; // quit if you're trying to overwrite an existing test } test = !!(test()); docElement.className += ' ' + (test ? '' : 'no-') + feature; ret[ feature ] = test; return ret; // allow chaining. },
Chrome 8.0 : _enableHTML5:true,
Chrome 8.0 : _version:1.6,
Chrome 8.0 => undefined
Firefox 3.6 : flexbox:false,
Firefox 3.6 : canvas:true,
Firefox 3.6 : canvastext:true,
Firefox 3.6 : webgl:false,
Firefox 3.6 : touch:false,
Firefox 3.6 : geolocation:true,
Firefox 3.6 : postmessage:true,
Firefox 3.6 : websqldatabase:false,
Firefox 3.6 : indexeddb:false,
Firefox 3.6 : hashchange:true,
Firefox 3.6 : history:false,
Firefox 3.6 : draganddrop:true,
Firefox 3.6 : websockets:false,
Firefox 3.6 : rgba:true,
Firefox 3.6 : hsla:true,
Firefox 3.6 : multiplebgs:true,
Firefox 3.6 : backgroundsize:true,
Firefox 3.6 : borderimage:true,
Firefox 3.6 : borderradius:true,
Firefox 3.6 : boxshadow:true,
Firefox 3.6 : textshadow:true,
Firefox 3.6 : opacity:true,
Firefox 3.6 : cssanimations:false,
Firefox 3.6 : csscolumns:true,
Firefox 3.6 : cssgradients:true,
Firefox 3.6 : cssreflections:false,
Firefox 3.6 : csstransforms:true,
Firefox 3.6 : csstransforms3d:false,
Firefox 3.6 : csstransitions:false,
Firefox 3.6 : fontface:true,
Firefox 3.6 : video:true,
Firefox 3.6 : audio:true,
Firefox 3.6 : localstorage:true,
Firefox 3.6 : sessionstorage:true,
Firefox 3.6 : webworkers:true,
Firefox 3.6 : applicationcache:true,
Firefox 3.6 : svg:true,
Firefox 3.6 : inlinesvg:false,
Firefox 3.6 : smil:false,
Firefox 3.6 : svgclippaths:true,
Firefox 3.6 : input:[object Object],
Firefox 3.6 : inputtypes:[object Object],
Firefox 3.6 : crosswindowmessaging:true,
Firefox 3.6 : historymanagement:false,
Firefox 3.6 : addTest:function (feature, test) { feature = feature.toLowerCase(); if (ret[feature]) { return; } test = !!test(); docElement.className += " " + (test ? "" : "no-") + feature; ret[feature] = test; return ret; },
Firefox 3.6 : _enableHTML5:true,
Firefox 3.6 : _version:1.6,
Firefox 3.6 => undefined
IE 8.0 : flexbox:false,
IE 8.0 : canvas:false,
IE 8.0 : canvastext:false,
IE 8.0 : webgl:false,
IE 8.0 : touch:false,
IE 8.0 : geolocation:false,
IE 8.0 : postmessage:true,
IE 8.0 : websqldatabase:false,
IE 8.0 : indexeddb:false,
IE 8.0 : hashchange:false,
IE 8.0 : history:false,
IE 8.0 : draganddrop:true,
IE 8.0 : websockets:false,
IE 8.0 : rgba:false,
IE 8.0 : hsla:false,
IE 8.0 : multiplebgs:false,
IE 8.0 : backgroundsize:false,
IE 8.0 : borderimage:false,
IE 8.0 : borderradius:false,
IE 8.0 : boxshadow:false,
IE 8.0 : textshadow:false,
IE 8.0 : opacity:false,
IE 8.0 : cssanimations:false,
IE 8.0 : csscolumns:false,
IE 8.0 : cssgradients:false,
IE 8.0 : cssreflections:false,
IE 8.0 : csstransforms:false,
IE 8.0 : csstransforms3d:false,
IE 8.0 : csstransitions:false,
IE 8.0 : fontface:true,
IE 8.0 : video:false,
IE 8.0 : audio:false,
IE 8.0 : localstorage:true,
IE 8.0 : sessionstorage:true,
IE 8.0 : webworkers:false,
IE 8.0 : applicationcache:false,
IE 8.0 : svg:false,
IE 8.0 : inlinesvg:false,
IE 8.0 : smil:false,
IE 8.0 : svgclippaths:false,
IE 8.0 : input:[object Object],
IE 8.0 : inputtypes:[object Object],
IE 8.0 : crosswindowmessaging:true,
IE 8.0 : historymanagement:false,
IE 8.0 : addTest:function (feature, test) { feature = feature.toLowerCase(); if (ret[ feature ]) { return; // quit if you're trying to overwrite an existing test } test = !!(test()); docElement.className += ' ' + (test ? '' : 'no-') + feature; ret[ feature ] = test; return ret; // allow chaining. },
IE 8.0 : _enableHTML5:true,
IE 8.0 : _version:1.6,
IE 8.0 => undefined
@airportyh
Copy link
Author

With the new update this is much easier now that document.body actually exists at start up. So just do

var script = document.createElement('script')
script.setAttribute('src', url)
document.body.appendChild(script)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment