JS文件提速方法: + H6 F: y& b3 O9 Z" `
把通常加载方式:<script src="dancead.js"></script>
9 L9 o& k ]- y改变成:<script type="text/javascript"> document.write("<scr"+"ipt src=\"dancead.js\"></sc"+"ript>") ; </script>
- u/ l! w3 @4 _, L G9 d5 S: |
. Y5 {9 W8 H' t! S lJS文件延迟加载方法:
$ h: P" o1 P5 @$ jJS延迟加载代码如下:<script language="JavaScript" src="" id="ToTwo"></script> ' X5 ?( _7 `+ ?2 }7 C! t1 P" S
<script> setTimeout("document.getElementById('ToTwo').src='http://www.xp37.com/include.js'; ",3000);//延时3秒 </script> |