整理:Google jQuery 引用地址大全和方法(转)

 

什么是google的js托管?

说的明白点,跟我们以往做法一样,只不过这时候的引用的js库是放在google服务器上的 
比如引用jquery,则使用路径  http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js即可。
也就是无论是 谁的网站,只要使用了将得到与在自己服务器引用一样的效果。
这当然有它的优点,要不然谁还大费周折搞什么托管

google 的优势何在?

google有着遍布世界各地的DNS服务器,这便成了它可以做为托管的有利条件
比如我买了个国 外的域名空间,在北京访问的时候,通过DNS得到国外服务器上的资源,也许这个服务器很忙所以准备呆会再理我,也许这个服务器传输资源的路径很慢
但是通 过google的DNS服务器,可以为我分配一个最近而且不那么忙的服务器为我提供托管在它上面的js库,这样可以提高加载的速度

google 托管的好处?

除了上面说的google拥有分布各地的DNS服务器,使用google托管还有一个好处就是有效地使用缓存
回到第一个问题,我在访问了a.html之 后又去访问一个名为b.html地文件
b.html引用了http://www.XXX.com/b/jquery.js,假设这两个 jquery版本是一样的
那么我在访问b.html,浏览器发现缓存里没有www.XXX.com/b/jquery.js,于是重新加载js 库。
但如果这两个文件都使用的是http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js,
那么访问b.html时只要使用访问a.html时缓存在浏览器里的js库即可,好处显而易见了

使用托管有不好的影响吗?

当然,任何好的东西都有不好的一面正所谓托管,那对google的依赖性一定是很强的了。
一旦google倒了,确实也是个大麻烦(但这应该是不可能的)
但是要是真有那个时候,我想google的这些服务器大概也早被某些怀旧的人买下来依旧供人们共享吧,但愿吧

所谓托管就是人家帮你管,个随人愿,还是看站长们自己抉择吧!
---------------------------------------------------------------------------------------------------

常用引用方法:

 
  1. <script type=text/javascript src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  2. <script>!window.jQuery && document.write('<script src="jquery.js"></script>');</script>

注释:引用google托管Jquery,不成功则使用本地Jquery

常用jQuery版本引用地址:

 
  1. 1.2.6:
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
  3. 1.3.2:
  4. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  5. 1.4.2:
  6. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
  7. 1.5.2:
  8. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
  9. 1.6.2:
  10. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
  11. 1.6.4:
  12. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
  13. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js" type="text/javascript"></script>
  14. 1.7.1:
  15. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  16. 1.7.2:
  17. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
  18. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
  19. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

最新版(last):

 
  1. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

百度CDN:

 
  1. http://libs.baidu.com/jquery/1.9.0/jquery.min.js

-------------------------------------------------------------------------------------------------------------------------------

本文转自: http://www.isaced.com/post-155.html

最后你还可以看看isaced发表的《[教程]EMLOG内部使用Google jQuery》 ,使用emlog内部函数调用最新的托管jQuery哦

如果不喜欢Google的托管CDN,那么可以试试《SAE公共资源库 》的Jquery托管

更多google的托管库可以访问 https://developers.google.com/speed/libraries/devguide
 
 
 
posted @ 2013-08-05 12:46  Daniel大东  阅读(393)  评论(0编辑  收藏  举报