// Add a script element as a child of the body
function downloadJSAtOnload(jsPath) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = jsPath;
document.body.appendChild(s);
}
//defer function for js load
function deferLoad(jsPath){
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", function(){downloadJSAtOnload(jsPath)}, false);
else if (window.attachEvent)
window.attachEvent("onload", function(){downloadJSAtOnload(jsPath)});
else
window.onload = function(){downloadJSAtOnload(jsPath)};
}
function downloadJSAtOnload(jsPath) {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = jsPath;
document.body.appendChild(s);
}
//defer function for js load
function deferLoad(jsPath){
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", function(){downloadJSAtOnload(jsPath)}, false);
else if (window.attachEvent)
window.attachEvent("onload", function(){downloadJSAtOnload(jsPath)});
else
window.onload = function(){downloadJSAtOnload(jsPath)};
}
No comments:
Post a Comment