拦截重写js和css的加载过程

const appendChild=document.head.appendChild
document.head.appendChild=function(dom) {
if(dom.tagName==='SCRIPT'){
//加载js
LCache.loadAll(dom.src,onload)
}else if(dom.tagName==='LINK'){
//加载js
LCache.loadAll(dom.href,onload)
}else{
return appendChild.apply(document.head,arguments);
}
}

const dom=document.createElement('script')
dom.src='a.js';
document.head.appendChild(dom)

  

posted @ 2022-03-04 15:07  无工时代  阅读(213)  评论(0编辑  收藏  举报