好记性不如烂笔头。

js延迟加载方案

<script>
function downloadJSAtOnload(){
   var elem = document.createElement("script");
   elem.src="defer.js";
   document.body.appendChild(elem);
};
if(window.addEventListener){
   window.addEventListener("load",downloadJSAtOnload,false);
}else if(window.attachEvent){
   window.attachEvent("onload",downloadJSAtOnload);
}else{
   window.onload = downloadJSAtOnload;
};
</script>