Created
June 28, 2014 09:01
-
-
Save ajinabraham/334a8e9db6980a2abc8d to your computer and use it in GitHub Desktop.
Load JavaScript Dynamically and Invoke something onLoad
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 require(file,callback){ | |
var head=document.getElementsByTagName("head")[0]; | |
var script=document.createElement('script'); | |
script.src=file; | |
script.type='text/javascript'; | |
//real browsers | |
script.onload=callback; | |
//Internet explorer | |
script.onreadystatechange = function() { | |
if (_this.readyState == 'complete') { | |
callback(); | |
} | |
} | |
head.appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment