Skip to content

Instantly share code, notes, and snippets.

@shawndumas
Created August 14, 2012 21:28
Show Gist options
  • Save shawndumas/3353194 to your computer and use it in GitHub Desktop.
Save shawndumas/3353194 to your computer and use it in GitHub Desktop.
JavaScript Script Loader
;(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);
@alexispurslane
Copy link

Awsome!

I figured it out and changed it around to suit my needs!

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