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. Experience the best Nuru Massage in Bangkok.
    Sensual and erotic massages, VIP service, soapy massage
    and happy ending moments in a luxurious setting — real photos,
    real masseuses.

  2. Ꮃhat i ddo not understood is in reality
    how you’re now not really a ⅼlot more neatly-appreciated than you may bee now.
    You’re so intelligent. You reaⅼize thus consideerablү in the case of
    tһis topic, made me in my opinion believе it from so many numerous angles.
    Ιts lікe women and men don’t seem to bbe involved until
    it is one thing tⲟ doo with Ꮃoman gaga! Your individuаl stսffs great.
    At all times maіntain it uρ!

    Ϝeeel free to surf to mʏ paɡe: drivemad

  3. I’m impressed, I must say. Rarely do I encounter a blog that’s
    equally educative and amusing, and let me tell you, you have hit the nail on the head.
    The problem is something that too few people are speaking intelligently
    about. I am very happy that I came across this in my search for
    something concerning this.

  4. I know this web page gives quality dependent posts and other information, is there any other site which offers these information in quality?

  5. Hi there, i read your blog occasionally and
    i own a similar one and i was just wondering if you get a lot of spam responses?
    If so how do you prevent it, any plugin or anything you can advise?
    I get so much lately it’s driving me mad so any support
    is very much appreciated.

  6. Thanks for the auspicious writeup. It actually was
    a amusement account it. Glance complicated to more introduced agreeable from you!
    By the way, how can we be in contact?

  7. What a material of un-ambiguity and preserveness of precious familiarity on the topic of unexpected emotions.

  8. With havin so much content and articles do you ever run into any issues of plagorism or copyright violation? My blog has a lot of
    unique content I’ve either created myself or outsourced but it seems a lot of it
    is popping it up all over the web without my permission.
    Do you know any ways to help protect against content from being
    stolen? I’d genuinely appreciate it.

  9. you’re actually a excellent webmaster. The web site loading speed is incredible.
    It seems that you’re doing any unique trick.

    Furthermore, The contents are masterwork. you’ve performed a excellent process in this topic!