Answers for "js appendchild wait for callback"

1

js appendchild wait for callback

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
});
Posted by: Guest on May-20-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language