如何延时加载外部JavaScript文件



如何延时加载外部JavaScript文件?为了提高网页的打开速度,尽可能的减小页面加载内容不失为一个好办法,比如延时加载图片等;今天为大家介绍的不是如何延时加载图片,而是延时加载JS.
以下提供几个可以实现此功能的JS,这些你都可以拿来试一试,看看你最喜欢哪一个,使用方法我就不多做介绍了,官网的示例都写得很清楚。本人建议使用RequireJS。

1. RequireJS RequireJS For Asynchronous Script Loading

site: http://www.andresvidal.com/jsl

2. Kongregate Asynchronous JavaScript Loader

site: https://gist.github.com/405172

3. yepnope – is an asynchronous conditional resource loader that’s super-fast


site:http://www.yepnopejs.com/

4. Head JS

site: http://www.headjs.com/

5. LAB.js

site: http://www.labjs.com/

reource: http://www.bennadel.com/blog/2230-Using-The-LAB-js-Script-Loader-With-jQuery-s-DOM-Ready-Event.htm