jquery - Javascript runtime add js / css, how to get progress -
i want runtime add css , javascripts. want sure loaded before going further cannot find how can check dynamic loading progress of added file.
this loading script. there basic js function i'm missing or maybe jquery?
function loadfileruntime(filename){ "use strict"; var filetype; var fileref; var lastindex = filename.indexof("?"); if(lastindex===0) { filetype = filename.substr(filename.lastindexof(".") + 1); }else{ filetype = filename.substring( filename.lastindexof(".")+1, lastindex ); } switch(filetype){ case "js": fileref = document.createelement('script'); fileref.setattribute("type","text/javascript"); fileref.setattribute("src", filename); break; case "css": fileref = document.createelement("link"); fileref.setattribute("rel", "stylesheet"); fileref.setattribute("type", "text/css"); fileref.setattribute("href", filename); break; } if (typeof fileref !== "undefined"){ document.getelementsbytagname("head")[0].appendchild(fileref); } }
Comments
Post a Comment