js appendchild ждать обратного вызова
function injectScript(src,callback){
var script = document.createElement('script');
script.src = src;
script.onload=function(){
callback();
}
document.head.appendChild(script);
}
injectScript('https://www.mysite.com/somescript.js', function(){
//the script is now all loaded
});
Friendly Hawk