手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

如何提高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加载速度

2 发布网站之后,使用 min版本。

如图 压缩版本和未压缩版本,体积差了180K。

如何提高Jquery加载速度

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

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

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

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

如何提高Jquery加载速度

请通过chrome的调试器,查看各个CDN的加载时间,综合选择适合自己网址的Jquery加速服务

如何提高Jquery加载速度

© 手抄报圈