Google 的 jQuery CDN 在中国可用吗?

发布于 2024-08-28 10:20:44 字数 526 浏览 7 评论 0 原文

有谁知道Google的jQuery CDN在中国是否可用?

http://code.google.com/apis/ajaxlibs/

我可能有一个项目,其中我需要支持多个国家/地区的本地化,包括中国大陆,并想知道是否需要找到替代方案,例如:

http://www.asp.net/ajax/CDN/

没关系,但我的理解是 Microsoft CDN 不支持 jQuery UI。

我已经检查了以下 Google 报告页面,但无法真正确定“网站”是否包含其 CDN 交付: http://www.google.com/prc/report.html

Does anyone know if Google's CDN for jQuery is available in China?

http://code.google.com/apis/ajaxlibs/

I might have a project where I'll need to support localization a variety of countries, including mainland China, and want to know if I'll need to find alternatives such as:

http://www.asp.net/ajax/CDN/

Which is okay, but my understanding is that the Microsoft CDN doesn't support jQuery UI.

I've checked over at the following Google report page, but can't really figure out if 'sites' includes their CDN delivery:
http://www.google.com/prc/report.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

奢望 2024-09-04 10:20:44

如果 CDN 不可用,您始终可以考虑加载备用 JQuery 源(可能是您自己的)。如果您愿意的话,可以提供后备副本。 Scott Galloway 有一篇很好的文章,类似这样的文章应该没问题:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>

<script type="text/javascript">
  if (typeof jQuery == 'undefined')
  {
     document.write(unescape("%3Cscript src='/Scripts/jquery-1.4.2.min.js' type='text/javascript'%3E%3C/script%3E"));
     document.write(unescape("%3Cscript src='/Scripts/jqueryui-1.7.2.min.js' type='text/javascript'%3E%3C/script%3E"));
  }
  </script>

我很欣赏这实际上并没有检查您的访问者是否可以访问 CDN,但它是确保您的网站的一个很好的解决方案仍然有效。 (即使在离线开发模式下也可以这样工作):)

You could always consider loading an alternative JQuery source (maybe your own) if the CDN is not available. A fall-back copy if you will. Scott Galloway had a good article on it, something like this should be OK:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>

<script type="text/javascript">
  if (typeof jQuery == 'undefined')
  {
     document.write(unescape("%3Cscript src='/Scripts/jquery-1.4.2.min.js' type='text/javascript'%3E%3C/script%3E"));
     document.write(unescape("%3Cscript src='/Scripts/jqueryui-1.7.2.min.js' type='text/javascript'%3E%3C/script%3E"));
  }
  </script>

I appreciate that this doesn't actually check if your visitors can access the CDN, but it's a good solution for making sure your site still works. (Even works in offline development mode this way) :)

寂寞美少年 2024-09-04 10:20:44

不。它不能被称为 "available" 也不能被称为 "reliable"

不可靠不值得信赖不负责任善变反复无常不规律< /code>、不稳定不可预测不稳定可变不稳定、<代码>脆弱和<代码>任意可能是更准确的描述(全部一起,也可以单独)。

中国的互联网和通信法规和法律由国有互联网服务提供商、商业公司和组织的省级政治部门大力实施 - 各自实施自己认为合适的审查制度

这些系统还会根据当前的政治或地缘政治事件定期更新。
例如,在政党峰会的一周,审查制度更加严格,系统变得“硬化”。另一个例子是政府(也包括地方政府)之间的过渡期或举办世界性活动,例如奥运会亚洲运动会等。再次强调 - 这些更改是LOCALPERIODICAL

换句话说,很难预测——但有清晰的模式。

除此之外,中国的法律法规(由于语言本身)广泛广泛开放供当地高级和初级官员解释。看到合适的——而你所看到的是中国特有的奇妙混乱。

中国政府开始禁用某些搜索或阻止结果 - 但由于系统是本地的,并且并不总是提供给正确的政治或技术官员 - 它可能会导致阻止整个范围的服务,如谷歌地图、字体、CDN 等。 (更不用说影响每个嵌入 tweet 或 facebook feed 的网站,加载时间增加 500% - 在许多情况下甚至超时失败)

最终结果是人们上面写的每个答案都是正确的和不正确的同时 。如果有人回答“是的,它有效”,它实际上意味着“是的,它对我有效,在我当前的位置,在当前的时间”

反之亦然。

我自己的经验是,在中国工作大约 5 年之后,大约 65% 是失败的。

编辑:当 CDN 失败时,这就是这个 SE 网站在中国的样子。

CDN 时堆栈溢出失败..

并且..

有趣的事实:在中国,上传上面的图片后,我自己无法查看它..:-)

另一种形式的失败CDN (图片托管)

Nop . It is can not be refereed to as "available" nor "reliable" .

undependable, untrustworthy, irresponsible, fickle, capricious, irregular, erratic, unpredictable, inconstant, mutable, slippery, fragile and arbitrary might be more accurate description ( all together and also each separately ).

China´s internet and communications regulations and laws are vigorously implemented by provincial political branches of state-owned ISPs, business companies, and organizations - each implementing it´s own censorship systems as it see fit .

These systems are also periodically updated in relation to current political or geopolitical events.
For example, in the week of a party summit , the censorship is much more strict and the systems get "hardened". Another example is the transition period between governments ( also local ) or the hosting of world wide events like the olympics, Asia games etc . again - those changes are LOCAL and PERIODICAL.

In other words, very hard to predict - but with a clear pattern.

Add on top of that the fact that the Chinese laws and regulations ( due to the language itself ) are widely and wildly open for interpretation of the local senior and junior officers as they see fit - and what you have is the wonderful chaos that is so characteristic of China.

The Chinese government began disabling certain searches or blocking the results - but since the systems are local , and not always given to the right political or technical officer - it can result in blocking a whole range of services like google maps, fonts, CDN Etc. ( not to mention affecting every site that Embades a tweet or facebook feed with a 500% increase on load time - and in many cases even a timeout failure )

The end result is that each of the answers that people wrote above is true and not true at the same time . If someone answer "yes, it works" it actually means "yes , it works FOR ME , at my CURRENT location, at the CURRENT TIME "

The same is true for the opposite .

My own experience is after about 5 years working in china is around 65% failure.

EDIT : This is how this SE site looks like in china when CDN fails..

Stack overflow when CDN fails ..

AND ..

Funny fact : In china , after uploading that image above , I myself can not view it .. :-)

Another form of faild CDN ( image hosting )

蹲在坟头点根烟 2024-09-04 10:20:44

是的,它可用,但在某些地区不稳定。

http://chineseoshifu.com/blog/china-hosted -javascript-libraries-jquery-dojo-boostrap.html

根据上面的文章,一些中国互联网公司也托管 jQuery 和其他流行的 Javascript 库,例如百度和新浪。这些公司托管的库位于中国境内的服务器上,因此速度更快、更稳定。

Yes it's available, but unstable in some areas.

http://chineseseoshifu.com/blog/china-hosted-javascript-libraries-jquery-dojo-boostrap.html

According to the article above, some Chinese Internet companies host jQuery and other popular Javascript libraries too, like Baidu and Sina. Libraries hosted by these companies are on servers within China so they are faster and more stable.

揪着可爱 2024-09-04 10:20:44

有时会不稳定。最好使用中国的cdn,例如163.com sina.com.cn

Some time it will be unstable. You‘d better use cdn of China, such as 163.com sina.com.cn

铁轨上的流浪者 2024-09-04 10:20:44

截至本周末,该功能在中国尚不可用。对我来说有点令人惊叹。无论如何,我喜欢后备机制!

As of this weekend, it's not available in China. Kind of a show-stopper for me. I like the fallback mechanism in any case!

清风不识月 2024-09-04 10:20:44

如果 Google CDN 有可能在中国被屏蔽,只需在您自己的网站上使用本地版本的 jQuery 即可。

不依赖 Google 还有其他优点 - 如果您正在编写大量 jQuery 代码,您可以将 jQuery 和您的应用程序全部压缩在一个文件中并保存一些 HTTP 请求。

Google 的闭包编译器可能会删除您需要的函数,从而为您节省大量字节不使用 - 尽管上次我检查它对于 jQuery 来说并没有很好地做到这一点。

If there's a chance the Google CDN would be blocked in China, just go ahead and use a local version of jQuery on your own site.

There are other advantages to not relying on Google too - if you're writing a lot of jQuery code you could compress jQuery and your app all in one file and save some HTTP requests.

Google's Closure Compiler may be able to save you a lot of bytes by removing functions you're not using - although last time I checked it didn't do this for jQuery very well.

生死何惧 2024-09-04 10:20:44

百度已托管cdn http://developer.baidu.com/wiki /index.php?title=docs/cplat/libs
但找不到jquery css

新浪CDN: http://lib.sinaapp.com/

http://jscdn.upai.com/: 没有 Bootstrap

我们在网站中实施了新浪 CDN。

此致
苏迪普塔·巴纳吉

Baidu has hosted cdn http://developer.baidu.com/wiki/index.php?title=docs/cplat/libs
But couldn't find jquery css

SINA CDN: http://lib.sinaapp.com/

http://jscdn.upai.com/: Don' have Bootstrap

We have implemented Sina CDN in our website.

Best Regards
Sudipta Banerjee

嘦怹 2024-09-04 10:20:44

正如其他答案所表明的那样,对于来自中国的访问者来说,使用 Google CDN 并不可靠。

要从 CDN 可靠地加载 jQuery,您必须回退到替代 CDN。如果您从 Google CDN 加载并回退到另一个 CDN,则访问者将不得不等待太长时间,第一个请求才会失败,然后浏览器才会将第二个请求发送到回退 CDN。我建议您使用替代 jQuery CDN 作为首选选项,并且仅在其他情况下才回退到 Google CDN一个已倒下。操作方法如下:

 <script src="https://pagecdn.io/lib/jquery/3.2.1/jquery.min.js"></script>
    <script>
        window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"><\/script>');
    </script>

我们正在以相反的方式进行操作,并使用其他一些 CDN 作为您的首选,并回退到 Google CDN 以避免失败的请求和等待时间。

As other answers suggest, no its not reliable to use Google CDN for visitors from China.

To reliably load jQuery from CDN, you have to fallback to alternative CDN. If you load from Google CDN and fall back to another one, your visitors will have to wait for too long for the first request to fail before the browser sends the second request to the fallback CDN. I would recommend you to use alternative jQuery CDN as preferred option, and fallback to Google CDN only if the other one is down. Here is how to do it:

 <script src="https://pagecdn.io/lib/jquery/3.2.1/jquery.min.js"></script>
    <script>
        window.jQuery || document.write('<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"><\/script>');
    </script>

We are doing it the opposite way and use some other CDN as your preferred option and fallback to Google CDN to avoid failed requests and waiting time.

水染的天色ゝ 2024-09-04 10:20:44

根据我的经验,Google CDN 上的 jQuery 库在中国不可用,当您尝试访问以下网址时,您将在浏览器控制台中收到错误
https://ajax.googleapis.com/ajax/ libs/jquery/1.12.4/jquery.min.js net::ERR_CONNECTION_CLOSED
https://ajax.googleapis.com/ajax/ libs/jquery/3.2.1/jquery.min.js net::ERR_CONNECTION_CLOSED

From my experience, the jQuery library on Google CDN is not available in China , when you try to access the following url, you will get error in console of the browser
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js net::ERR_CONNECTION_CLOSED
https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js net::ERR_CONNECTION_CLOSED

同尘 2024-09-04 10:20:44

是的,它在中国可用,我现在正在使用它。

Yes, It's available in China, and I am using it right now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文