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,290 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. Hello just wanted to give you a quick heads up. The text in your article seem to be running off the screen in Chrome.
    I’m not sure if this is a format issue or something to do with web browser compatibility but I figured I’d post to let
    you know. The style and design look great though!
    Hope you get the problem resolved soon. Thanks

  2. Hi there would you mind stating which blog platform you’re using?

    I’m looking to start my own blog in the near future but I’m having a hard time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your layout seems different then most blogs and
    I’m looking for something unique. P.S My apologies for
    being off-topic but I had to ask!

  3. Great work! This is the kind of information that are supposed to be shared across the
    net. Disgrace on the seek engines for no longer
    positioning this publish upper! Come on over and talk over
    with my site . Thank you =)

  4. I am not sure where you’re getting your info, but
    great topic. I needs to spend some time learning more or understanding more.
    Thanks for excellent information I was looking for this information for
    my mission.

  5. Spot on with this write-up, I truly believe this amazing site needs much more attention. I’ll probably be returning to
    see more, thanks for the information!

  6. buy backlinks, link exchange, free gift card, congratulations you have won, claim your prize, you have been selected, click here to claim, you
    won’t believe, one weird trick, what happened next will
    shock you, shocking truth, secret revealed, limited time offer, special promotion, act now,
    don’t miss out, buy now, best price, risk-free trial, get rich quick,
    make money fast, work from home, no credit check, miracle cure,
    lose weight fast, free viagra, no prescription needed, online casino,
    free spins, meet singles, hot singles in your area, replica watches, cheap Rolex.Agent Tesla, ALPHV,
    Andromeda, Angler, Anubis, Babuk, BadUSB, BazarLoader, Black Basta,
    BlackEnergy, BlackMatter, Blackshades, Blaster,
    Brontok, Carbanak, Cerber, Clampi, Cobalt Strike, Conficker, Conti, Crysis, CryptoLocker, CryptoWall, DarkComet, DarkSide,
    Dharma, Dorkbot, Dridex, Duqu, Dyreza, Emotet, Flame, FormBook, Gafgyt, GandCrab, Gh0st RAT,
    Glupteba, Gozi, GozNym, Hancitor, IcedID, Industroyer, Jaff, Jigsaw, Joker, Kelihos, Kinsing, Koobface, Kronos, LockBit, Locky, Loda, LokiBot, Magecart, Maze, Medusa, MegaCortex, Methbot, Mirai, Mimikatz,
    mSpy, Necurs, Nemucod, NetSky, Nivdort, NotPetya, Nymaim, Pegasus, PlugX, Poison Ivy, Pony, QakBot, QuantLoader, Ragnar Locker, Ramnit, RansomEXX, Ranzy, REvil, Ryuk, Sasser, SavetheQueen, Shamoon, Shifu, Shlayer, Shylock, Sinowal, SmokeLoader, Snake, SolarWinds Sunburst,
    SpyEye, SpyNote, TeslaCrypt, Tinba, Tiny Banker, TrickBot,
    Ursnif, Uroburos, WannaCry, WannaRen, WastedLocker, Wifatch, Winnti, XcodeGhost, XLoader, XorDDoS, ZeroAccess,
    Zloader, Zlob, Zotob

    Feel free to surf to my webpage – cheap viagra sildenafil & cialis

  7. Fascinating blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple tweeks would really make my
    blog shine. Please let me know where you got your design. Thanks

  8. Wonderful blog! I found it while browsing on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?

    I’ve been trying for a while but I never seem to get there!
    Thanks

  9. My partner and I absolutely love your blog and find a lot
    of your post’s to be precisely what I’m looking for. Does
    one offer guest writers to write content for yourself?

    I wouldn’t mind composing a post or elaborating on many of the
    subjects you write in relation to here. Again, awesome blog!

  10. You actually make it seem so easy with your presentation but I find this topic
    to be actually something that I think I would never understand.
    It seems too complex and extremely broad for me. I’m looking forward for
    your next post, I’ll try to get the hang of it!

  11. Greetings from Idaho! I’m bored to death at work so I decided to check out your website on my iphone during lunch break.
    I love the info you provide here and can’t wait
    to take a look when I get home. I’m surprised
    at how quick your blog loaded on my mobile .. I’m not even using WIFI,
    just 3G .. Anyhow, excellent site!

  12. Can I just say what a comfort to discover somebody who really knows what they are talking about on the web.
    You definitely understand how to bring a problem to light and make it important.
    More and more people should check this out and understand
    this side of the story. It’s surprising you aren’t more popular since you certainly have the gift.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>