Friday, June 1, 2012

Is there a link to the "latest' jquery library on Google APIs?


I use the following for a jquery link in my <script> tags:




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



Just wondered if anyone had discovered whether there's a link to the "latest" version:



Something like the following (which doesn't work):




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



(Obviously not necessarily a great plan to link your code to potentially changing libraries but useful in development)


Source: Tips4all

10 comments:

  1. You can use:


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


    To get the most recent version in the 1.x.x family or you could use:


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


    To get the most recent version in the 1.7.x family.

    EDIT:

    In case anyone is interested Microsoft is also hosting jquery:

    http://ajax.Microsoft.com/ajax/jQuery/jquery-1.7.1.min.js

    EDIT 2:

    jQuery is now hosting a version on their CDN:

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

    EDIT 3:

    A list of the latest libraries and frameworks (including download links) can be found at scriptsrc.net.

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

    this is the minified version, always up-to-date

    ReplyDelete
  3. Be aware that caching headers are different when you use "direct" vs. "latest" link from google.

    When using http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js

    Cache-Control: public, max-age=31536000


    When using http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js

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

    ReplyDelete
  4. Not for nothing, but you shouldn't just automatically use the latest library. If they release the newest library tomorrow and it breaks some of your scripts, you are SOL but if you use the library you used to develop the scripts, you will ensure they will work.

    ReplyDelete
  5. Yes there is.

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

    ReplyDelete
  6. If you do this you always have the latest versions.

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


    Then call it with:

    google.setOnLoadCallback(function(){jQuery(function($) {

    // Enter your code block here

    });});

    ReplyDelete
  7. No. There isn't..

    But, for development there is such a link on the jQuery code site.

    ReplyDelete
  8. Google doesn't allow the reference of jQuery's latest version.
    When jQuery changes its major version, then you'll have to change the link.
    Media Temple does. Here are the links:
    - Development version - Production (Minified) version.

    These links always refer to the latest versions.

    ReplyDelete
  9. jQuery also doesn't allow you to call their latest file over SSL, a consideration if you want to use jQuery in a shopping cart etc.

    e.g.

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


    will give you a security error.

    Google's API will let you call over SSL:

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

    ReplyDelete
  10. Here's a page where you can find links to the latest versions of jQuery, jQueryUI and Themes for Google and Microsoft CDN's. This page automatically updates with the latest links from the CDN.
    http://lab.abhinayrathore.com/jquery_cdn/

    ReplyDelete