jQuery 链接与下载? [英] jQuery Linking vs. Download?
问题描述
哪种方式更好?在 http://ajax.googleapis.com 链接到 jQuery 包.或者在本地下载适当的文件和链接?有关系吗?链接有没有可能消失?或者网上的文件有没有可能更新,最好有链接?好奇.
Which way is better? To link to the jQuery Pack at http://ajax.googleapis.com. Or to download the appropriate file and link locally? Does it matter? Is there a chance the link may disappear? Or is there a chance the file online will be updated, and it's better to link to it? Curious.
谢谢,特蕾西
推荐答案
来自 Google Code 站点:
From the Google Code site:
Google 直接使用密钥每个图书馆工作的利益相关者并接受最新的稳定版本当它们被释放时.一旦我们举办了一场发布一个给定的库,我们是致力于托管该版本无限期.
Google works directly with the key stake holders for each library effort and accepts the latest stable versions as they are released. Once we host a release of a given library, we are committed to hosting that release indefinitely.
Google 托管 jQuery 库的一个要点是将其缓存在一个地方.考虑以下场景:
One of the main points of Google hosting the jQuery library is so that it is cached in a single place. Consider the following scenario:
- 用户访问站点 A
- 站点A在同一个域中有jQuery,因此文件由浏览器下载
- 用户访问站点 B
- 站点 B 在同一个域中有 jQuery,因此浏览器会再次下载该文件.
现在,如果我们都从 Google 服务器获取 jQuery,则场景如下:
Now if we all fetched jQuery from the Google servers, the scenario goes like this:
- 用户访问站点 A
- 站点 A 从 Google 加载 jQuery,因此它由浏览器下载
- 用户访问站点 B
- 站点 B 从 Google 加载 jQuery,但浏览器已经下载并缓存了它,因此再次获取文件是即时的.
这篇关于jQuery 链接与下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!