1function injectScript(src,callback){
2 var script = document.createElement('script');
3 script.src = src;
4 script.onload=function(){
5 callback();
6 }
7 document.head.appendChild(script);
8}
9injectScript('https://www.mysite.com/somescript.js', function(){
10 //the script is now all loaded
11});