Created
January 14, 2010 19:59
-
-
Save ryanmcgrath/277443 to your computer and use it in GitHub Desktop.
This file contains 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
// ... | |
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