引用google的在线jQuery库的地址和方法

 

 

       为了实现各种绚丽的效果,你的网站是否调用了众多的Ajax库呢?尽管这样做能是你的网站增色不少,但几十K的Ajax库也会让你的网站丢失速度。既然如此,那我们到底是要速度还是要特效呢?

  今天就大家介绍一个两全其美的办法。

   一般的网站都只是调用各种Ajax库,并不用对其内容进行修改,所以我们可以借助第三方服务器上的Ajax库。Google Code就给我们提供了各种Ajax库的托管链接,我们可以直接调用这些链接而不用把整个库上传到主机,大大减少主机的压力,对于速度较慢的主机效果很明 显哦。当然,如果你的主机足够强劲以至于能和Google媲美的话,我建议还是把库放在自己主机上。

  这里给大家整理在Google托管的各种Ajax库,大家也可以到Google Code看看详细信息

注:每个版本的两个链接中,第一个是压缩版的,第二个是完全版,可用于二次开发。建议调用时使用压缩版,体积减小很多,但没有功能变。

 

google ajax libraries API 是Google的一个项目(http://code.google.com/apis/ajaxlibs/documentation/index.html#AjaxLibraries)。

它提供当前流行的各种Javascript库的快速引用方式。(官方承诺永久可用!)

使用google ajax libraries API 引用 jQuery库有两种方式。

第一种方法:是使用google提供的API进行导入

 

<script src="http://www.google.com/jsapi?key=Goolge"></script>

<script type="text/javascript">

    google.load("jquery","1.3.2",{uncompressed:true});

    google.setOnLoadCallback(initialize);

  function initialize(){

    //函数或方法

  } 

</script>

 

// 测试引用是否成功

$(document).ready(function(e) {

    alert('test!');

});

google.load()函数有3个参数,第一个参数为js库的名称,如:"jquery"或 "extjs"等;

第二个参数为该库的版本号,如:"1.3.2";

第三个参数设定是否使用压缩版本的库文件,使用未压缩版本格式: {uncompressed:true} ;

前两个参数必选,第三个参数为可选参数 

 

第二种方法:直接引用google服务器上的jquery库文件

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

// 测试引用是否成功

$(document).ready(function(e) {

    alert('test!');

});

 

google服务器上存放jquery版本号有jquery-1.2.6, jquery-1.3.2, jquery-1.4.2, jquery-1.5.2, jquery-1.6.2, jquery-1.6.4,  jquery-1.7.1, jquery-1.7.2, jquery-1.8.0, jquery-1.8.1, jquery-1.8.2

开发者可以根据所需而选择

google jQuery 1.4.2引用文件

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

google jQuery 1.5.2引用文件

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

jQuery UI (此库依赖于jQuery。载入jQuery UI模块需先载入之前jQuery模块。)

1.5.3

http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js

http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.js

1.5.2

http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js

http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.js

 

MooTools
1.2.1

http://ajax.googleapis.com/ajax/libs/mootools/1.2.1/mootools-yui-compressed.js

http://ajax.googleapis.com/ajax/libs/mootools/1.2.1/mootools.js

1.11

http://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools-yui-compressed.js

http://ajax.googleapis.com/ajax/libs/mootools/1.11/mootools.js

Prototype
1.6.0.3

http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js

1.6.0.2

http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js

script.aculo.us
注:此库依赖于Prototype。载入script.aculo.us模块需先载入之前Prototype模块。
1.8.2

http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js

1.8.1

http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.1/scriptaculous.js

dojo
1.2.3

http://ajax.googleapis.com/ajax/libs/dojo/1.2.3/dojo/dojo.xd.js

http://ajax.googleapis.com/ajax/libs/dojo/1.2.3/dojo/dojo.xd.js.uncompressed.js

1.2.0

http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dojo/dojo.xd.js

http://ajax.googleapis.com/ajax/libs/dojo/1.2.0/dojo/dojo.xd.js.uncompressed.js

1.1.1

http://ajax.googleapis.com/ajax/libs/dojo/1.1.1/dojo/dojo.xd.js

http://ajax.googleapis.com/ajax/libs/dojo/1.1.1/dojo/dojo.xd.js.uncompressed.js

SWFObject
2.1

http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js

http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject_src.js

Yahoo! 用户界面库 (YUI)
2.6.0

http://ajax.googleapis.com/ajax/libs/yui/2.6.0/build/yuiloader/yuiloader-min.js

http://ajax.googleapis.com/ajax/libs/yui/2.6.0/build/yuiloader/yuiloader.js

 

参考地址:1.http://blog.sina.com.cn/s/blog_5b68649a0101athd.html

                  2.http://www.yzzmf.com/html/qianduankaifa/jsjq/2011-10-03/1968.html

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值