Created
February 22, 2011 13:25
-
-
Save phiggins42/838658 to your computer and use it in GitHub Desktop.
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 addScript(src){ | |
var script = document.createElement("script"); | |
script.src = src; | |
script.onload = script.onreadystatechange = function(e){ | |
if(e && e.type == "load" || /loaded|complete/.test(script.readyState)){ | |
script.onload = script.onreadystatechange = null; | |
console.log("foo.js added and ready"); | |
} | |
} | |
return (document.head || document.getElementsByTagName("head")[0]).appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment