Skip to content

Instantly share code, notes, and snippets.

@learning
Created June 15, 2012 03:27
Show Gist options
  • Save learning/2934507 to your computer and use it in GitHub Desktop.
Save learning/2934507 to your computer and use it in GitHub Desktop.
Load Script
var loadScript = function(url, callback){
var d = document,
script = d.createElement('script');
script.type = 'text/javascript';
if(script.readyState){
script.onreadystatechange = function(){
if(script.readyState == 'loaded' || script.readyState == 'complete'){
script.onreadystatechange = null;
callback.call(this);
}
};
}else{
script.onload = function(){
callback.call(this);
};
}
script.src = url;
d.getElementsByTagName('head')[0].appendChild(script);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment