JS AppendChild Tunggu panggilan balik

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