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. Howdy! This blog post couldn’t be written any better!

    Looking at this article reminds me of my previous roommate!
    He continually kept talking about this. I will forward this post to him.

    Fairly certain he’s going to have a very good read.

    Many thanks for sharing!

  2. Good day very cool site!! Man .. Beautiful .. Wonderful ..
    I will bookmark your site and take the feeds also? I am satisfied to search out so many useful info right here within the submit, we want work out more strategies
    in this regard, thank you for sharing. . . . .
    .

  3. Thanks for sharing your thoughts. I truly appreciate your efforts and I
    am waiting for your next write ups thanks once again.

  4. Usually I don’t read post on blogs, but I wish to say that this write-up
    very compelled me to take a look at and do so! Your writing
    taste has been surprised me. Thank you, quite great article.

  5. Kaizenaire.ϲom excels in accumulating Singapore’ѕ promotions from
    favorite firms and brands.

    Ϲonstantly ߋn tһе lookout foг bargains, Singaporeans mаke the most of Singapore’ѕ credibility as a global shopping paradise.

    Participating іn funny shows at local cinemas brings laughter
    tο funny Singaporeans, аnd remember tо stay updated on Singapore’s newest promotions ɑnd shopping deals.

    ComfortDelGro оffers taxi and public transport solutions, appreciated Ƅy Singaporeans
    f᧐r thеir dependable trips ɑnd comprehensive
    network ɑcross the city.

    Shopee, a leading е-commerce sʏstem sіa, offеrs everything from gizmos
    tօ grocery stores lah, beloved Ьy Singaporeans fοr іts
    flash sales and user-friendly app lor.

    Stack Seng Leong protects vintage kopitiam vibes ᴡith butter
    kopi, preferred by nostalgics fоr unmodified
    customs.

    Maintain cοming Ƅack lor, Kaizenaire.ⅽom
    always ցot brand-new shopping discounts tо make you pleased sіа.

    mу web-site … promotions singapore

  6. Nice post. I was checking constantly this blog and I’m impressed!
    Very helpful information particularly the last part :) I care for
    such information much. I was looking for this particular info for
    a long time. Thank you and good luck.

  7. Hi there! Would you mind if I share your blog with my myspace group?
    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Many thanks

  8. You should take part in a contest for one of the greatest websites online.
    I’m going to highly recommend this site!

  9. Hello there, just became aware of your blog through Google,
    and found that it’s truly informative. I’m gonna watch out for brussels.
    I’ll appreciate if you continue this in future. Numerous people will be benefited from your writing.
    Cheers!

  10. Heya i’m for the primary time here. I came across this board and I in finding It truly helpful & it helped me out much.

    I hope to provide something again and aid others like
    you aided me.

  11. I was suggested this website by way of my cousin. I’m now not positive whether this publish is written by means of him
    as no one else recognise such designated about my trouble.
    You are wonderful! Thanks!

  12. fantastic publish, very informative. I wonder why the opposite experts of this sector don’t notice
    this. You must proceed your writing. I’m sure, you’ve a huge readers’ base already!

  13. 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 waste your intelligence on just posting videos
    to your site when you could be giving us something enlightening to read?