Skip to content

Instantly share code, notes, and snippets.

@ajinabraham
Created June 28, 2014 09:01
Show Gist options
  • Save ajinabraham/334a8e9db6980a2abc8d to your computer and use it in GitHub Desktop.
Save ajinabraham/334a8e9db6980a2abc8d to your computer and use it in GitHub Desktop.
Load JavaScript Dynamically and Invoke something onLoad
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