Skip to content

Instantly share code, notes, and snippets.

@ryanmcgrath
Created January 14, 2010 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmcgrath/277443 to your computer and use it in GitHub Desktop.
Save ryanmcgrath/277443 to your computer and use it in GitHub Desktop.
// ...
load: function(url, callback) {
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.src = url;
if(newScript.readyState) {
newScript.onreadystatechange = function() {
if(newScript.readyState == "loaded" || newScript.readyState == "complete") {
newScript.onreadystatechange = null;
callback();
}
};
} else {
newScript.onload = function() { callback(); }
}
document.documentElement.firstChild.appendChild(newScript);
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment