function loadScript(url,callback) {
var script = document.createElement("script");
script.type = "text/javascript";
if(script.readyState) {
script.onreadystatechange = function() {
if(script.readyState == "complete" || script.readyState == "loaded") {
callback();
}
}
}else {
window.onload = function() {
callback();
}
}
script.src = url;
document.head.appendChild(script);
}
loadScript("js/jquery.js",function() {
console.log(document.readyState);
})
javascript 异步加载js文件
原文作者:code_xin~
原文地址: https://blog.csdn.net/weixin_44456354/article/details/111996490
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
原文地址: https://blog.csdn.net/weixin_44456354/article/details/111996490
本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。