如何提高Jquery加载速度

2024-10-31 15:57:39

Jquery 目前最新版本是 2.X (注意:2.X 不支持IE,6,7,8。所以不过相兼容6,7,8需要使用1.X版本)。

jquery网站上是这么说的:

jQuery 2.xhas the same API as jQuery 1.x, butdoes not support Internet Explorer 6, 7, or 8.All the notes in thejQuery 1.9 Upgrade Guideapply here as well. Since IE 6/7/8 are still relatively common, we recommend using the 1.x version unless you are certain no IE 6/7/8 users are visiting the site. Please read the2.0 release notescarefully.

目前jquery 已经达到了上百K。min压缩版本也很大

所以下面说一下如何 提高 jquery在网站的加载速度:

1 使用合适的版本,不一定最新的jquery库就最适合你的网站。可能你的js代码,可能只需要一个1.6版本的Jquery。但是却引用了一个1.8版本的jquery。无意中体积增加了几十K.

如何提高Jquery加载速度

3 如果网站带宽比较紧张或是所在机房不是全网机房。可以使用jquery CDN加速。

让CDN加速给客户端浏览器下载jquery,可以减少不少带宽。

CND jquery 网址:(直接在jquery 官网,download页面即可)

JQ官网提供CND加速,google,microsoft 也提供。如图:

如何提高Jquery加载速度

猜你喜欢