码迷,mamicode.com
首页 > 编程语言 > 详细

延迟加载JavaScript

时间:2015-05-07 20:05:05      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

 1 function downloadJSAtOnload() {
 2     var element = document.createElement("script");
 3     element.src = "defer.js";
 4     document.body.appendChild(element);
 5 }
 6 if (window.addEventListener)
 7     window.addEventListener("load", downloadJSAtOnload, false);
 8 else if (window.attachEvent)
 9     window.attachEvent("onload", downloadJSAtOnload);
10 else window.onload = downloadJSAtOnload;

 

延迟加载JavaScript

标签:

原文地址:http://www.cnblogs.com/leilin007/p/4485722.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!