Created
August 14, 2012 21:28
-
-
Save shawndumas/3353194 to your computer and use it in GitHub Desktop.
JavaScript Script Loader
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
;(function (name, self, d) { | |
self[name] = function (src, cb) { | |
cb = cb || function () {}; | |
var newScriptTag = d.createElement('script'), | |
firstScriptTag = d.getElementsByTagName('script')[0]; | |
newScriptTag.src = src; | |
newScriptTag.async = true; | |
newScriptTag.onload = newScriptTag.onreadystatechange = function () { | |
(!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete') && (cb()); | |
}; | |
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag); | |
} | |
})('lodar', this, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awsome!
I figured it out and changed it around to suit my needs!