javascript文件的同步加载与异步加载实现原理

javascript文件的同步加载与异步加载实现原理
在html的script再次引用js文件的使用方法
if(location.pathname=="/System/index.html"){
document.write("<script src='test.js'><"+'/'+"script>");
// document.write("<script type='text/javascript' src='a.js'></script>");//js转义字符
console.log("跳转页面/Sytem/index.html");
}else{
console.log(location.pathname)
console.log("其他yemain");
}
页面实现效果,如下图所示(异步加载js成功,但是404代表没有找到)

原文地址:https://www.cnblogs.com/wsw8384/p/8927779.html