我在<script>标记中使用以下jQuery链接:

http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js

是否有指向“最新”版本的链接?类似以下内容(不起作用):

http://ajax.googleapis.com/ajax/libs/jquery/latest/jquery.js

(显然,将代码链接到可能变化的库并不一定是一个好计划,但在开发中很有用。)


在jQuery 1.11.1之前,您可以使用以下URL获取jQuery的最新版本:

https://code.jquery.com/jquery-latest.min.js-jQuery托管(缩小)https://code.jquery.com/jquery-latest.js-jQuery托管(未压缩)https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js-谷歌托管(缩小)https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js-谷歌托管(未压缩)

例如:

<script src="https://code.jquery.com/jquery-latest.min.js"></script>

然而,自jQuery1.11.1以来,jQuery和Google都停止更新这些URL;它们将永远固定在1.11.1。没有可使用的受支持的替代URL。有关为什么会出现这种情况的解释,请参阅本博客文章;不要使用jquery-latest.js。

两个主机都支持https和http,因此可以根据需要更改协议(或使用协议相关URI)

另请参见:https://developers.google.com/speed/libraries/devguide

没有。。

但是,对于开发,jQuery代码站点上有这样一个链接。

请注意,当您使用谷歌的“直接”链接与“最新”链接时,缓存头是不同的。

使用时http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js

Cache-Control: public, max-age=31536000

使用时http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js

Cache-Control: public, max-age=3600, must-revalidate, proxy-revalidate

不要使用这个答案。该URL指向jQuery1.11(并且总是如此)。

以上片段的基本学分

http://code.jquery.com/jquery-latest.min.js是缩小的版本,始终是最新的。

并非一无是处,但您不应该只是自动使用最新的库。如果他们明天发布最新的库,并且它破坏了您的一些脚本,那么您就是SOL,但是如果您使用用于开发脚本的库,那么您将确保它们能够正常工作。

是的。

http://code.jquery.com/jquery-latest.min.js

Use:

<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
//<![CDATA[
    google.load("jquery", "1");
    //google.load("jqueryui", "1");
    //google.load("swfobject", "1");
//]]>
</script>

注意:上面的代码段将坚持1.7.1或1.11.1。

我的建议是对CDN jQuery版本进行硬编码:<script src=“//ajax.googleapis.com/ajax/libs/jQuery/2.1.4/jQuery.min.js”></script>

您可以在此处找到Google CDN的最新库:https://developers.google.com/speed/libraries/

或者使用jQuery CDN:https://code.jquery.com/

jQuery也不允许您通过SSL调用他们的最新文件,如果您想在购物车等中使用jQuery,这是一个考虑因素。

e.g.

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

会给你一个安全错误。

Google的API将允许您通过SSL调用:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("jquery", "1.7");
</script>

http://lab.abhinayrathore.com/jquery_cdn/是一个页面,您可以在其中找到指向最新版本jQuery、jQuery UI和Google和Microsoft CDN主题的链接。

此页面会自动更新CDN中的最新链接。

您可以通过以下任一方式使用jQuery库的最新版本。

Google Ajax API CDN(也支持通过HTTPS的SSL)<script type=“text/javascript”src=“http://ajax.googleapis.com/ajax/libs/jquery/1.7.2“></script>/jquery.min.jsMicrosoft CDN(也支持通过HTTPS的SSL)<script type=“text/javascript”src=“http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js“></script>Ajax CDN发布、Microsoft Ajax CDN文档jQuery CDN(通过Media Temple)<script type=“text/javascript”src=“http://code.jquery.com/jquery-1.7.2.min.js“></script>**精简版<script type=“text/javascript”src=“http://code.jquery.com/jquery-1.7.2.js“></script>**开发(完整)版本

这个怎么样?

http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js

我想这总是最新版本-如果我错了,请纠正我。

不要使用jquery-latest.js

此文件不再更新(它将永远在v1.11.1上)。此外,它的缓存寿命非常短(消除了使用CDN的好处),因此最好选择jQuery的版本。

jQuery博客的更多详情:http://blog.jquery.com/2014/07/03/dont-use-jquery-latest-js/