Is Google’s CDN for jQuery available in China?
Asked Answered
C

10

26

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

Crinoline answered 9/4, 2010 at 12:39 Comment(3)
HTML 5 Boilerplate offers a solution: github.com/h5bp/html5-boilerplate/blob/5.3.0/dist/doc/…Baseball
just found out after a client complained. will never use cdns ever againCondillac
Nope. Its not available. But you can still use it. See: https://mcmap.net/q/42267/-best-way-to-use-google-39-s-hosted-jquery-but-fall-back-to-my-hosted-library-on-google-failPneumatometer
M
29

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) :)

Meyers answered 9/4, 2010 at 12:54 Comment(4)
Note that my client in China has reported that the page simply hangs at "waiting for ajax.googleapis.com". This method could introduce long or never-ending delays before getting to the check to see if jQuery is undefined. I'm not sure if there's a way around this except to either a) have server serve a different version to users in China, or b) using one of the various hacks to detect user IP client-side and doing the same. Neither are ideal.Adaxial
If Google provides a jQuery CDN from the US, maybe Baidu provides the same in China? Seems like a reliable fallback would be a Chinese jQuery provider. In reading HTML5Boilerplate docs today, I'm probably just going with their solution: github.com/h5bp/html5-boilerplate/blob/5.3.0/dist/doc/…Baseball
@Adaxial That is correct. I'm now in Shanghai but all the pages using these CDN just keep hanging for over 30 seconds.Moyer
This answer does not work. See: https://mcmap.net/q/42267/-best-way-to-use-google-39-s-hosted-jquery-but-fall-back-to-my-hosted-library-on-google-failPneumatometer
C
21

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 )

Costmary answered 27/2, 2014 at 6:40 Comment(1)
I loved this. I am in China though.Amulet
S
4

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.

Siena answered 5/4, 2013 at 14:52 Comment(0)
C
3

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.

Corso answered 9/4, 2010 at 12:48 Comment(0)
B
3

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

Brnaby answered 28/11, 2011 at 8:32 Comment(1)
Do you have specific links for Chinese variants?Hangchow
D
3

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!

Daze answered 31/3, 2012 at 22:30 Comment(0)
S
1

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

Swiger answered 12/9, 2014 at 12:29 Comment(0)
A
1

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.

Arizona answered 30/10, 2019 at 12:51 Comment(0)
D
0

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

Dorison answered 3/9, 2020 at 1:59 Comment(0)
H
-5

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

Hallux answered 29/7, 2010 at 2:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.