您的位置:首页 > Web前端 > JQuery

Google与微软为jQuery等类库提供CDN服务

2011-09-08 17:09 531 查看
以前在网站中都是这么引入jquery脚本库的:

< script type="text/javascript" src="/Comm/jQuery.min.js">< /script>

有时还要引入其它比较大的脚本类库,如:Prototype,每次引入时都得考虑:这么大的东西客户打开网页时要多郁闷啊。

现在好了,Google与Microsoft为jQuery,Prototype,MooTools等类库提供CDN服务,这样一来,不在客户在哪访问网站都是通过CDN访问这些脚本,提高了加载速度,减少了加载延迟并获得更好的缓存。

如:

< script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"><
/script>

推荐大家使用

相关链接:

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

Microsoft: http://www.asp.net/ajaxlibrary/cdn.ashx

Google提供的API最多,常用的他全有,像flash: swfobject


下载 jQuery

共有两个版本的 jQuery 可供下载:一份是精简过的,另一份是未压缩的(供调试或阅读)。

这两个版本都可从 jQuery.com 下载。


CDN HOSTED JQUERY

A number of large enterprises provide hosted copies of jQuery on existing CDN networks
that are available for public use. Below are links to the CDN-hosted copies of jQuery that you may hotlink to.

Google Ajax API CDN

http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js

Google
Ajax CDN Documentation

Microsoft CDN

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.3.min.js

Ajax
CDN Announcement, Microsoft
Ajax CDN Documentation

jQuery CDN (via Media
Temple)

http://code.jquery.com/jquery-1.6.3.min.js Minified
version

http://code.jquery.com/jquery-1.6.3.js Source
version


库的替代

Google 和 Microsoft 对 jQuery 的支持都很好。

如果您不愿意在自己的计算机上存放 jQuery 库,那么可以从 Google 或 Microsoft 加载 CDN jQuery 核心文件。


使用 Google 的 CDN

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs
/jquery/1.4.0/jquery.min.js"></script>
</head>


使用 Microsoft 的 CDN

<head>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery
/jquery-1.4.min.js"></script>
</head>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: