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. First of all I would like to say wonderful blog!
    I had a quick question in which I’d like to ask if you do not mind.
    I was curious to find out how you center yourself and
    clear your mind prior to writing. I’ve had a difficult time clearing my mind in getting my thoughts out.
    I do take pleasure in writing but it just seems like the first 10 to 15
    minutes tend to be wasted just trying to figure out how to begin. Any suggestions or hints?
    Kudos!

  2. It’s awesome to go to see this web page and reading the views of all mates on the topic of this paragraph, while I am also
    eager of getting familiarity.

  3. Hi there everyone, it’s my first pay a visit at this web page,
    and post is in fact fruitful in favor of me, keep up posting these types
    of posts.

  4. Very nice post. I just stumbled upon your weblog and
    wished to say that I’ve really enjoyed browsing your blog posts.
    After all I’ll be subscribing to your rss feed and I hope you write again soon!

  5. Normally I don’t read article on blogs, but I would like to say that
    this write-up very pressured me to check out and do it! Your writing taste
    has been amazed me. Thanks, quite great post.

  6. I’ve been explooring for a little bit for any
    high-quality articles oor weblog posts in this kind of space .

    Exploring in Yahoo I eventually stumbled upon thgis website.
    Studyibg this info So i’m happy to exhibiit that I’ve an incredibly excellent uncanny feeling I discovered just
    wwhat I needed. I most no doubt will maie certain to don?t put
    out of your mind this webb site and give itt a look regularly.

  7. Its like you read my mind! You seem to know a lot about this,
    like you wrote the book in it or something. I think that you could
    do with a few pics to drive the message home a bit,
    but instead of that, this is great blog. A fantastic read.
    I will certainly be back.

  8. Have you ever considered publishing an ebook or guest authoring on other
    blogs? I have a blog centered on the same ideas you discuss
    and would really like to have you share some
    stories/information. I know my visitors would value your work.
    If you’re even remotely interested, feel free to send me an e-mail.

  9. Hi, I do think this is an excellent website. I stumbledupon it
    ;) I may return once again since i have book-marked it.
    Money and freedom is the best way to change, may you
    be rich and continue to help others.

  10. Pretty nice post. I just stumbled upon your blog and wished to say
    that I’ve really enjoyed browsing your blog posts. After all
    I’ll be subscribing to your rss feed and I hope you write again soon!

  11. If some one needs to be updated with hottest technologies after that he
    must be visit this web site and be up to date everyday.

  12. First off I would like to say wonderful blog! I had a quick question which I’d like to ask
    if you do not mind. I was curious to find out how you center yourself and clear your head prior to writing.
    I have had difficulty clearing my mind in getting my thoughts out.

    I truly do enjoy writing however it just seems like the first
    10 to 15 minutes are generally wasted simply just trying to figure out how to begin. Any ideas or
    hints? Appreciate it!

    Review my web blog – display screen led

  13. If some one needs to be updated with most up-to-date technologies afterward he must be pay a visit this site and be up to date daily.

  14. My brother recommended I may like this blog. He was totally right.
    This submit truly made my day. You can not consider simply
    how a lot time I had spent for this information! Thanks!

  15. Thanks for any other informative site. Where else may I am getting that kind
    of information written in such an ideal way?
    I have a venture that I am just now running on, and I’ve been at the look
    out for such info.

  16. Thanks for some other wonderful post. The place else may just anyone
    get that type of information in such an ideal method of writing?
    I’ve a presentation next week, and I am on the
    look for such information.

  17. Ⴝimplү want to say your article is as surprising. The cleɑrneѕs in уour post is јust
    excellent аnd i can assume you’re an expert on this subject.
    Well with your permissiоn allow me to grab
    your RSS feed to keep updated with fоrthcoming post. Thanks a million and please continue the enjoyable work.

    Here is my ⲣage … beach towels

  18. If you desire to obtain a great deal from this post then you have to apply these methods
    to your won webpage.

  19. This paragraph presents clear idea for the new visitors of blogging, that in fact how
    to do blogging and site-building.