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. Apkslot situs resmi provider apk slot 777 dengan bonus mingguan slot terbesar,
    provider lengkap, dan jackpot progresif setiap hari.

  2. Hey there, You’ve done a great job. I will definitely
    digg it and personally recommend to my friends. I’m sure they’ll be benefited from this site.

  3. It’s a shame you don’t have a donate button! I’d most certainly donate to this
    outstanding blog! I suppose for now i’ll settle
    for book-marking and adding your RSS feed to my Google account.
    I look forward to brand new updates and will share this site with my Facebook group.
    Talk soon!

  4. Thank you a lot for sharing this with all of us
    you really know what you’re speaking about! Bookmarked.
    Please additionally discuss with my site =).
    We can have a hyperlink change arrangement among us

  5. Hey there! I simply would like to give you a big thumbs up for your excellent
    information you have right here on this post.
    I’ll be coming back to your site for more soon.

  6. What’s up, its nice piece of writing concerning media print, we all be aware of
    media is a wonderful source of information.

  7. I don’t even know how I ended up here, but I thought this post was
    great. I do not know who you are but definitely you are going
    to a famous blogger if you are not already ;) Cheers!

  8. Whats up this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted to get guidance
    from someone with experience. Any help would be enormously appreciated!

  9. It is perfect time to make some plans for the future and it is time to be happy.
    I have read this post and if I could I wish to suggest you
    few interesting things or advice. Perhaps you could write next articles referring to this article.
    I want to read more things about it!

  10. I am not positive where you’re getting your information,
    however great topic. I needs to spend some time finding out much more or understanding more.
    Thank you for great info I was looking for this information for my
    mission.

  11. Hi there would you mind letting me know which web host you’re working with?
    I’ve loaded your blog in 3 completely different web browsers and I must say this blog loads a lot faster then most.
    Can you suggest a good hosting provider at a fair price? Kudos, I appreciate
    it!

  12. Good replies in return of this question with genuine
    arguments and describing the whole thing regarding that.

  13. Refresh Renovation Broomfield
    11001 Ꮃ 120th Ave 400 suite 459a,
    Broomfield, CⲞ 80021, United Stateѕ
    +13032681372
    Bookmarks – Gracie,

  14. “`spintax

    Ahaa, its fastidious conversation on the topic of Omegle at this place at this weblog.
    I have read all that, so now me also commenting at this place.