Last active
August 29, 2015 14:15
-
-
Save trevor-atlas/78b33f809c41ebf5238b to your computer and use it in GitHub Desktop.
Cutting the mustard: http://timkadlec.com/2014/10/reducing-javascript-bloat-with-shoestring/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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