问题描述
有人知道中国的jQuery CDN是否可用吗?
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:
没关系,但是我的理解是Microsoft CDN不支持jQuery UI.
Which is okay, but my understanding is that the Microsoft CDN doesn't support jQuery UI.
我已经检查了以下Google报告页面,但无法真正确定站点"是否包括其CDN交付: http://www.google.com/prc/report.html
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
推荐答案
如果CDN不可用,您总是可以考虑加载备用JQuery源(可能是您自己的).如果需要,可以使用后备副本. 斯科特·加洛韦(Scott Galloway)上有一篇不错的文章,应该可以这样:
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>
我很欣赏,这实际上并不能检查您的访问者是否可以访问CDN,但这是确保您的网站仍然可以正常使用的很好的解决方案. (甚至可以以这种方式在离线开发模式下工作):)
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) :)
这篇关于Google的jQuery CDN是否在中国可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!