jQuery链接与下载? [英] jQuery Linking vs. Download?

查看:122
本文介绍了jQuery链接与下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪种方式更好?要链接到 http://ajax.googleapis.com 上的jQuery Pack。还是在本地下载相应的文件和链接?有关系吗?有可能链接可能会消失吗?还是有机会在线更新文件,最好链接到它?好奇。



谢谢,
Tracy

解决方案

Google代码网站:


Google直接与每个图书馆工作的
利益相关者
一起工作,并接受最新的稳定版本
,因为它们被发布。一旦我们承担给定图书馆的
版本,我们将
承诺无限期地托管该版本


Google托管jQuery库的要点之一是将其缓存在一个地方。请考虑以下情况:


  1. 用户访问站点A

  2. 站点A在同一个域上具有jQuery ,所以该文件由浏览器下载

  3. 用户访问站点B

  4. 站点B在同一个域上具有jQuery,因此该文件由浏览器第二次。

现在,如果我们都从Google服务器上获取了jQuery,情况就是这样的:


  1. 用户访问网站A

  2. 网站A从Google加载jQuery,因此可以通过浏览器下载

  3. 用户访问站点B

  4. 站点B从Google加载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.

Thanks, Tracy

解决方案

From the Google Code site:

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.

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:

  1. User visits site A
  2. Site A has jQuery on the same domain, so the file is downloaded by the browser
  3. User visits site B
  4. Site B has jQuery on the same domain, so the file is downloaded by the browser a second time.

Now if we all fetched jQuery from the Google servers, the scenario goes like this:

  1. User visits site A
  2. Site A loads jQuery from Google, so it's downloaded by the browser
  3. User visits site B
  4. Site B loads jQuery from Google, but the browser already downloaded it and cached it, so fetching the file again is instantaneous.

这篇关于jQuery链接与下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆