延迟加载js文件
<!doctype html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Document</
title
>
</
head
>
<
body
>
<
script
>
setTimeout(function(){ //延迟5秒
var body = document.getElementsByTagName('body')[0];
var scr = document.createElement('script');//创建一个script节点
scr.setAttribute('src','test1.js'); //给script节点添加路径
body.appendChild(scr);
},5000);
</
script
>
</
body
>
</
html
>