Skip to content

Instantly share code, notes, and snippets.

@pastleo
Created January 5, 2014 20:23
Show Gist options
  • Save pastleo/8273354 to your computer and use it in GitHub Desktop.
Save pastleo/8273354 to your computer and use it in GitHub Desktop.
useful function when you need to import js without html...
function loadJS(url,loadFinished){
if(typeof loadFinished != 'function')
loadFinished=function(){};
rs_nav.message("JS from "+url+" start to load...");
var JS = document.createElement('script');
JS.setAttribute('src', url);
if (document.getElementsByTagName('head').item(0) == null)
document.getElementsByTagName('html').item(0).appendChild(document.createElement('head'));
JS.onload = function(){
rs_nav.message("JS from "+url+" is loaded!");
loadFinished();
};
JS = document.getElementsByTagName('head').item(0).appendChild(JS);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment