为什么我应该将Google的CDN用于jQuery? [英] Why should I use Google's CDN for jQuery?

查看:118
本文介绍了为什么我应该将Google的CDN用于jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这对于某些人来说可能是显而易见的,但是我一直在想:为什么我要依赖 Google的服务器为我的网站托管jQuery?

This may be obvious to some, but I've been wondering: why should I depend on Google's server to host jQuery for my site?

是不是因为这样加载速度更快?

Is it only because it loads faster this way?

推荐答案

这是因为:

  1. 它增加了可用的并行性.
    (大多数浏览器一次只能从任何给定站点下载3或4个文件.)

  2. 这增加了发生缓存命中的可能性.
    (随着越来越多的网站遵循这种做法,更多的用户已经准备好文件了.)

  3. 它可以确保有效载荷尽可能小.
    (Google可以以多种格式(例如GZIP或DEFLATE)预压缩文件.下载时间非常短,因为它是超级压缩的,并且不是即时压缩的.)

  4. 它减少了服务器使用的带宽量.
    (Google基本上提供了免费带宽.)

  5. 这可确保用户在地理位置上得到密切的响应.
    (Google在全球范围内拥有服务器,从而进一步减少了延迟.)

  6. (可选)它们将自动使您的脚本保持最新状态.
    (如果您想飞过裤子的座位,"可以随时使用他们提供的任何脚本的最新版本.这些漏洞可以解决安全漏洞,但通常只会破坏您的工作.)
  1. It increases the parallelism available.
    (Most browsers will only download 3 or 4 files at a time from any given site.)

  2. It increases the chance that there will be a cache-hit.
    (As more sites follow this practice, more users already have the file ready.)

  3. It ensures that the payload will be as small as possible.
    (Google can pre-compress the file in a wide array of formats (like GZIP or DEFLATE). This makes the time-to-download very small, because it is super compressed and it isn't compressed on the fly.)

  4. It reduces the amount of bandwidth used by your server.
    (Google is basically offering free bandwidth.)

  5. It ensures that the user will get a geographically close response.
    (Google has servers all over the world, further decreasing the latency.)

  6. (Optional) They will automatically keep your scripts up to date.
    (If you like to "fly by the seat of your pants," you can always use the latest version of any script that they offer. These could fix security holes, but generally just break your stuff.)

这篇关于为什么我应该将Google的CDN用于jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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