Google的jQuery庫

來源:互聯網
上載者:User

發現google伺服器上有很多jquery庫:
http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js(54.43kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js(55.91kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js(76.76kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js(83.91kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js(89.52kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js(92.62kb)
http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js(91.44kb)

理論上來說有下面一些優勢:
1、採用Google的CDN-Content Delivery Network(內容分髮網絡)載入jquery庫。Google離你最近!
2、更好的緩衝技術。
  當瀏覽器檢測到同樣版本的指向Google的連結,它就會知道這是下載同一個檔案,不僅是Google的伺服器會返回一個304(不需要修改檔案的指令,即伺服器上的檔案未改動過)來回複一個重複的請求,而且會命令瀏覽器的緩衝該檔案長達一年的時間。
3、減少伺服器的請求。
4、它是免費的。

項目中引用Google JQuery庫:

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

註:第二行用來解決最近Google極度不穩定而導致無法正常載入的問題。

有時候並不知道頁面是否已經載入了指令碼,可以這樣:

<script type=text/javascript> !window.jQuery && document.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"><\/script >'); </script><script type=text/javascript> !window.jQuery && document.write('<script type="text/javascript" src="js/jquery-1.8.3.min.js"><\/script >'); </script><script type="text/javascript">$(function(){// do somethings here.});</script>

網頁載入樣本:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.