1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What is 'jQuery Source'?

Discussion in 'XenForo Questions and Support' started by Vilandra, Jan 8, 2011.

  1. Vilandra

    Vilandra Active Member

    Hi all :) I'm dumb and don't really know which option is the best to choose here. What is it and is it better to use the local source or choose an external one? Thanks!
    AlexandrosD likes this.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Unless you have a specific reason to be using a different jQuery library, you can just leave it on local which means it will run from your own server.

    However, setting it to Google will most likely mean most visitors will already have a cached version on their PC.

    jQuery is software which enhances the browsing experience with little bits of eye-candy, animations, pop-ups, overlays, etc.
    Vilandra likes this.
  3. Vilandra

    Vilandra Active Member

    Thanks so much Brogan :)
  4. Max Hodges

    Max Hodges Member

    why do they give us an option?
  5. Luke F

    Luke F Well-Known Member

    Free CDNs :)
  6. Max Hodges

    Max Hodges Member

    oic, because jquery is large, so it would help reduce bandwidth?
  7. Max Hodges

    Max Hodges Member

    found some discussion on another site:

    The main point of the CDN is caching. If a user hits 100 JQuery sites, the library will only be downloaded once, and the remaining 99 sites will pull it from the local cache. From an operation cost, you also get to offload the cost of server Javascript to Google. As an added bonus, I also find it easier as a developer to kick off a new project by just linking to the CDN – no need to download and copy the latest version of JQuery.
    Great. So when not to use a CDN?
    Obviously, whenever you’re working offline. This sometimes occurs as a developer working locally, and with Single Page Applications like TiddlyWiki. (The next “major minor” release of TiddlyWiki, v2.5 is JQuery-powered.)
    Another case would be when you can deliver faster than the CDN, and care about that. This might be the case when all users are close to the server. Even then, though, you won’t get the local cache benefit from users who already have the JQuery.
    Finally, privacy and security concerns. Using the CDN, you are trusting the CDN to faithfully serve JQuery and relying on no third-parties injecting funniness in between the CDN and your user’s browser. If anything went wrong here, your user could be subject to a world of XSS and CSRF attacks. Or, in a more mundane scenario, the CDN might simply go down, thus breaking your web app. Furthermore, you’re giving the CDN data about your users this way. Although Google doesn’t use cookies, others might; and even if they don’t, the IP number is going to be sent back to them. The referrer – being your website – will also be sent to them, so they can, if they want, track your website’s usage.
    For many websites, though, it’s great that we can use a reliable CDN like Google’s to fetch JQuery fast.

    Amin Sabet likes this.
  8. Tigratrus

    Tigratrus Well-Known Member

    Another reason you might prefer to use the local copy would be to avoid the possibility that the version Google serves via the CDN might be upgraded to a newer version that causes some functionality in XF to break. You have no control over the version on the CDN, so you wouldn't be able to test it first to make sure it doesn't conflict with anything on your site.
  9. Onimua

    Onimua Well-Known Member

    Actually it seems like you do, since the CDN used here specifies a specific version (check the source).

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> 
  10. Forsaken

    Forsaken Well-Known Member

    Not at all.

    XenForo uses jQuery 1.4.4 (At least my board does), and it grabs that version from the CDN's listed.

    Most CDN's that host jQuery keep all previous versions.

    I'll kill you Oni :mad:
  11. Tigratrus

    Tigratrus Well-Known Member

    Heh. Fair enough. Hadn't seen that it was versioned in the CDN. :)
    Obviously that makes a lot of sense, I suppose I was generalizing from the way I've seen CDN's used via an origin pull.
    Well that gets my foot chewing out of the day for the evening... Must remember to add some pepper to my socks ;).
  12. Forsaken

    Forsaken Well-Known Member

    Most hosted APIs keep an archive of previous versions, just so people will not have to worry about changes breaking their site/project.
  13. Despair

    Despair Active Member

    Actually the jquery source on google is pretty flexible:
    http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js - uses the latest version of 1, which is currently 1.5.1, if 1.5.2 came out, it would soon use 1.5.2. Later on if 1.6.0 is released, it'll use that version.
    Similarly, if you use http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js it will use the latest version of 1.5, but not 1.6 and on.

    If you explicitly state to use 1.5.1 in the URL:
    http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js and version 1.5.2 came out, you'd still be serving the 1.5.1.

Share This Page