Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #appendchild #wait #callback
ADD COMMENT
Topic
Name
5+3 =