Answers for "delay external javascript file load"

0

delay external javascript file load

//load external js file into header after 2 seconds
setTimeout(function() {
    var headerEl = document.getElementsByTagName("head")[0];   
    var scriptEl = document.createElement('script');
	    scriptEl.type = 'text/javascript';
    	scriptEl.src = 'http:/www.mywebsite.com/myscript.js';
    	headerEl.appendChild(scriptEl);
}, 2000);
Posted by: Guest on April-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language