Skip to content

Instantly share code, notes, and snippets.

@trevor-atlas
Last active August 29, 2015 14:15
Show Gist options
  • Save trevor-atlas/78b33f809c41ebf5238b to your computer and use it in GitHub Desktop.
Save trevor-atlas/78b33f809c41ebf5238b to your computer and use it in GitHub Desktop.
window.myApp = {};
/*! loadJS: load a JS file asynchronously. [c]2014 @scottjehl, Filament Group, Inc. (Based on http://goo.gl/REQGQ by Paul Irish). Licensed MIT */
function loadJS( src, cb ){
"use strict";
var ref = window.document.getElementsByTagName( "script" )[ 0 ];
var script = window.document.createElement( "script" );
script.src = src;
script.async = true;
ref.parentNode.insertBefore( script, ref );
if (cb && typeof(cb) === "function") {
script.onload = cb;
}
return script;
}
function loadJS(src,cb){...}
if ('querySelector' in document && 'addEventListener' in window) {
window.myApp.cutsMustard = true;
document.documentElement.className += " mustard";
loadJS("main.js");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment