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

  1. I savor, lead to I discovered exactly what I used
    to be looking for. You have ended my 4 day lengthy hunt!
    God Bless you man. Have a great day. Bye

  2. It’s in reality a great and useful piece of info. I’m happy that you shared this helpful info
    with us. Please keep us up to date like this. Thank you
    for sharing.

  3. Great blog here! Also your website loads
    up very fast! What web host are you using? Can I get your
    affiliate link to your host? I wish my site loaded up
    as quickly as yours lol

  4. Its such as you read my thoughts! You appear to grasp
    so much approximately this, such as you wrote the guide
    in it or something. I feel that you simply can do with a
    few p.c. to force the message home a bit, but other than that,
    this is wonderful blog. An excellent read. I’ll certainly
    be back.

  5. I know this if off topic but I’m looking into starting my own blog and was wondering what all
    is needed to get setup? I’m assuming having a blog like yours would
    cost a pretty penny? I’m not very internet smart so I’m not
    100% certain. Any suggestions or advice would be greatly appreciated.
    Thanks

  6. Hello, I want to subscribe for this blog to get newest updates, thus
    where can i do it please help out.

  7. Very great post. I just stumbled upon your blog and wished to say that
    I have really loved browsing your blog posts. In any case I will be subscribing for your
    rss feed and I’m hoping you write again soon!

  8. Thanks for every other great post. Where else
    could anybody get that kind of info in such a perfect approach of
    writing? I have a presentation subsequent week, and I’m on the look for such info.

  9. First of all I want to say excellent blog! I had a quick question that I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear your mind prior to writing.
    I have had difficulty clearing my thoughts in getting my thoughts out.
    I do take pleasure in writing but it just seems like the first 10 to 15 minutes are usually wasted
    just trying to figure out how to begin. Any ideas or hints?
    Many thanks!

  10. Hey there! Would you mind if I share your blog with my myspace group?
    There’s a lot of folks that I think would really appreciate your content.
    Please let me know. Thank you

  11. Undeniably believe that which you stated. Your favorite reason seemed to be on the web the easiest
    thing to be aware of. I say to you, I definitely get annoyed while people consider worries that
    they just do not know about. You managed to hit the nail upon the top and defined
    out the whole thing without having side-effects , people could take a signal.
    Will likely be back to get more. Thanks

  12. fantastic points altogether, you simply won a new reader.

    What may you suggest about your submit that you just made a few days in the past?
    Any positive?

  13. I all the time used to study paragraph in news papers but now as I am a user of internet thus from
    now I am using net for articles, thanks to web.

  14. Everything is very open with a clear description of the issues.

    It was truly informative. Your site is very useful. Thanks for sharing!

  15. Wonderful website. Lots of helpful info here. I’m sending it to several buddies ans also sharing in delicious.

    And of course, thank you on your sweat!

  16. Hello to all, how is the whole thing, I think every one is getting more from this web
    page, and your views are nice in favor of new visitors.

  17. Does your website have a contact page? I’m having a tough time locating it but,
    I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing
    it grow over time.

  18. Wow, that’s what I was seeking for, what a information! existing here at this
    blog, thanks admin of this web page.

  19. I am really impressed with your writing
    skills and also with the layout on your blog.

    Is this a paid theme or did you modify it yourself? Anyway keep
    up the nice quality writing, it’s rare to see a great blog
    like this one nowadays.

  20. You’re so cool! I don’t suppose I’ve read through something like that before.
    So great to find another person with original thoughts on this issue.
    Seriously.. many thanks for starting this up. This web site is one thing that is needed on the
    web, someone with some originality!

  21. Have you ever considered publishing an ebook or guest authoring on other blogs?
    I have a blog centered on the same subjects you discuss and would really
    like to have you share some stories/information. I know my
    readers would value your work. If you are even remotely interested, feel
    free to send me an email.

  22. Interesting blog! Is your theme custom made or did
    you download it from somewhere? A theme like yours with a few simple adjustements would really make my blog
    jump out. Please let me know where you got your design. Kudos