jQuery CDN as A Named Module In RequireJS

If you want RequireJS to fetch jQuery from a CDN, you’ll need to tell it to do so using the “paths” config:

require.config({
paths: {
"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"
}
});

As I understand it, if you want to use the local file fallback code a la html5bp you’re out of luck. For those of you who don’t know, the local file fallback code allows you to load jQuery from your own domain if the CDN version fails to load. It looks like this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.8.2.min.js"><\/script>')</script>

Arguably, if you’re using jQuery it is likely to be a global requirement rather than a requirement for one or two modules. The same sort of thing with BackboneJS. It might be better to place these global requirements in the HTML for your pages (before the RequireJS script) to save typing ‘jquery’ and ‘backbone’ in all your module definitions.

22,429 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. Le service client de Betify est accessible 24h/24 et 7j/7, ce qui permet aux joueurs de recevoir de l’aide à tout moment, peu importe
    leur fuseau horaire.

  2. It’s awesome to pay a visit this website and reading the
    views of all colleagues on the topic of this piece of writing, while I am also keen of getting knowledge.

  3. This site definitely has all the information I needed about this subject and didn’t know who to ask.

  4. I every time used to read paragraph in news papers but now as I
    am a user of internet therefore from now I am using net for articles or reviews,
    thanks to web.

  5. you are in reality a good webmaster. The web site loading pace is amazing.

    It seems that you’re doing any distinctive trick. Moreover, The contents are masterwork.
    you have done a fantastic task on this topic!

  6. Excellent goods from you, man. I’ve understand your stuff previous
    to and you’re just extremely magnificent. I actually
    like what you’ve acquired here, certainly like what you’re saying and the way
    in which you say it. You make it entertaining and you still take care of to keep it sensible.

    I can’t wait to read far more from you. This is
    actually a great website.

  7. І Ԁon’t even know how Ι stopped uр right һere, however I
    belieѵed thiѕ put uр ѡɑs great. I do not understand
    whⲟ you might ƅe bᥙt certainly yoս are going to a famous blogger ѡhen үou are not already.
    Cheers!

    my homepage: สล็อต

  8. Hi there, just became alert to your blog through Google, and found that it’s really informative.
    I am gonna watch out for brussels. I will
    be grateful if you continue this in future. Many people will be benefited from
    your writing. Cheers!

  9. After I initially commented I appear to have clicked the -Notify me when new comments are added- checkbox and now every time a
    comment is added I receive 4 emails with the exact same comment.
    Is there a way you are able to remove me from that service?

    Appreciate it!

  10. Write more, thats all I have to say. Literally, it seems
    as though you relied on the video to make your point. You clearly know what youre talking about, why throw
    away your intelligence on just posting videos to your weblog when you could be giving us something informative to read?