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

以前在网站中都是这么引入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 和 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>

posted @ 2011-09-08 17:09  petercao  阅读(7872)  评论(0编辑  收藏  举报