JS文件提速方法:
8 s7 A* S1 [2 w R把通常加载方式:<script src="dancead.js"></script> 1 P7 J+ x6 x0 W9 I) J, g
改变成:<script type="text/javascript"> document.write("<scr"+"ipt src=\"dancead.js\"></sc"+"ript>") ; </script> 1 e1 U; G k3 O; V
- Q l+ c2 h9 e6 _/ q
JS文件延迟加载方法:
~2 Y/ k" }8 z" H, xJS延迟加载代码如下:<script language="JavaScript" src="" id="ToTwo"></script> " z9 t. c8 b, B% ^* ^
<script> setTimeout("document.getElementById('ToTwo').src='http://www.xp37.com/include.js'; ",3000);//延时3秒 </script> |