jQuery CDN failover 的方式...

之前有在其他網站上看到 failover 的技巧,但剛剛才發現 jQuery 官方網站上也用上了類似的技巧,將 Google (ajax.googleapis.com) 與 EdgeCast (code.jquery.com) 的 CDN:

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

雖然 jQuery 網站上是放在開頭,但放在 HTML 最後面也有一樣的效果...

One thought on “jQuery CDN failover 的方式...”

  1. 第一個 <script> 如果是 Error 500 就算了,如果是卡住然後 timeout 那做了 fallback 只是卡完之後程式到底會不會跑這樣 ...

Leave a Reply

Your email address will not be published. Required fields are marked *