<!--[if !IE]> --> <script type="text/javascript" src="//code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> window.jQuery || document.write("<script src='../assets/js/jquery.min.js'>"+"<"+"/script>"); </script> <!-- <![endif]--> <!--[if IE]> <script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> window.jQuery || document.write("<script src='../assets/js/jquery1x.min.js'>"+"<"+"/script>"); </script> <![endif]-->
一是采用CDN加载。若是CDN加载失败,则退回到本地加载。javascript
二是采用协议无关的加载网址(使用双斜线表示),同时支持http协议和https协议。java
目前经常使用的jQuery CDN有如下这些。jquery
Google CDNajax
Microsoft CDNasp.net
jQuery CDNide
jsDelivr CDNgoogle
上面这段代码最好放到网页尾部。若是须要支持IE 6/7/8,就使用jQuery 1.x版,不然使用最新版。spa