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. Unquestionably believe that which you stated.

    Your favorite justification appeared to be on the internet
    the simplest thing to be aware of. I say to you, I certainly get irked while people think about worries that they just
    don’t know about. You managed to hit the nail upon the top as
    well as defined out the whole thing without having side
    effect , people can take a signal. Will probably be back to get more.

    Thanks

  2. Hey there I am so happy I found your weblog, I really found you by mistake, while I was looking on Google for
    something else, Anyhow I am here now and would just like to
    say kudos for a incredible post and a all round interesting blog (I also love the
    theme/design), I don’t have time to go through
    it all at the moment but I have saved it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome job.

  3. Great post. I was checking continuously this blog and I am impressed!
    Extremely useful information specifically the last part :) I care for such info a lot.
    I was seeking this particular information for a long time.
    Thank you and good luck.

  4. My spouse and I stumbled over here by a different web page and thought I should check things out.
    I like what I see so now i’m following you. Look forward to finding out about your
    web page yet again.

  5. Hi, i believe that i saw you visited my website so i got here to return the favor?.I’m attempting to in finding issues too enhance my web site!I suppose its ook to make use off
    a ffew of you concepts!!

  6. An intriguing discussion is worth comment. I think that you need to write more about this issue, it may not be
    a taboo matter but generally folks don’t discuss such topics.

    To the next! All the best!!

  7. Add obscurity for privacy or decorative purpose as primary design element

    Decorative pattern glass with wide selection of distinctive texture like floral
    pattern, geometric shape and abstract motif

    Wide application including door insert, shower enclosure, partition, railing and glass furniture

    discover more at newspacehospitality.com

  8. I truly love your site.. Pleasant colors & theme.
    Did you create this web site yourself? Please reply back as I’m looking to create my very own website and would
    love to learn where you got this from or what
    the theme is named. Appreciate it!

  9. Thanks for some other informative website. The place else may just I get that type
    of information written in such a perfect manner? I have a challenge that I’m just now working on, and I
    have been on the glance out for such info.

  10. LUCK8 – Website chính thức LUCK8F – cổng game đổi thưởng
    uy tín tại Việt Nam. Khám phá giải trí đẳng
    cấp, hệ thống game đa dạng, bảo mật cao, mượt mà cùng cơ hội trúng thưởng khủng và dịch vụ chuyên nghiệp hàng đầu.