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.

6,889 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. This design is wicked! You definitely know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to
    start my own blog (well, almost…HaHa!) Excellent job.
    I really loved what you had to say, and more than that, how you presented it.

    Too cool!

  2. Great site you have here but I was wanting to know if you knew of any user discussion forums that cover the same topics discussed in this article?
    I’d really like to be a part of community where I can get advice from other experienced individuals that share the same interest.
    If you have any suggestions, please let me know. Kudos!

  3. Hi Dear, are you actually visiting this site regularly, if so after
    that you will without doubt take fastidious know-how.

  4. Definitely believe that which you said. Your favorite reason seemed 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
    plainly do not know about. You managed to hit the nail upon the top as well as
    defined out the whole thing without having side-effects ,
    people could take a signal. Will likely be back to
    get more. Thanks

  5. It’s fantastic that you are getting thoughts from this piece of writing as
    well as from our argument made at this place.

  6. It’s a shame you don’t have a donate button! I’d most certainly
    donate to this superb blog! I guess for now i’ll settle for book-marking and adding your RSS feed to
    my Google account. I look forward to new updates and will share this blog with my Facebook group.
    Chat soon!

  7. You’re so interesting! I don’t suppose I’ve truly read through
    something like this before. So nice to discover someone with original thoughts on this subject matter.
    Really.. thank you for starting this up. This web site is one thing that’s needed on the internet, someone with a bit of
    originality!

  8. I have been exploring for a little bit for any high-quality articles or blog posts
    in this sort of area . Exploring in Yahoo I at last stumbled upon this site.
    Studying this information So i am happy to exhibit that I’ve a very excellent uncanny feeling I discovered exactly what I needed.
    I such a lot surely will make sure to do not omit this
    web site and provides it a glance on a constant basis.

  9. Wow that was strange. I just wrote an extremely long comment but after
    I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say fantastic blog!

  10. My developer is trying to persuade me to move to
    .net from PHP. I have always disliked the idea because of the
    costs. But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year and am worried about switching to another platform.
    I have heard fantastic things about blogengine.net. Is there a way I can transfer all my
    wordpress posts into it? Any kind of help would be really appreciated!

  11. I’m not sure where you are getting your info, but great topic.
    I needs to spend some time learning much more or understanding
    more. Thanks for great information I was looking for this info for my mission.

  12. Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog that automatically tweet my newest
    twitter updates. I’ve been looking for a plug-in like this for
    quite some time and was hoping maybe you would have some experience with something
    like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates.

  13. A motivating discussion is definitely worth comment.
    There’s no doubt that that you should write more on this subject, it
    may not be a taboo subject but generally people do not talk about such issues.
    To the next! All the best!!

  14. You are so cool! I don’t believe I have read something like this before.

    So great to discover someone with a few unique thoughts on this issue.
    Seriously.. thank you for starting this up.

    This website is something that’s needed on the internet, someone with some originality!

  15. Лука Модрич футбол дүйнөсүнүн символу болуп калды.Эгер Лука Модрич кетсе Реалдын орто талаасы өзгөрөт. Лука Модрич оюнду көзөмөлдөөнүн чебери. Лука Модричтин жашы 39 болсо да оюну жаштардыкындай. Легенданын бардык трофейлери бир тизмекте — ыңгайлуу окула турган: Лука Модрич трофеи. Хорватиянын эң атактуу оюнчусу дал ушул Модрич. Лука Модрич Реалга келгенде команда өзгөргөн. Модрич согуш жылдарында чоңойгон бирок футбол аны сактап калды. Бул оюнчу ар бир клуб үчүн кымбат сыйлык болот. Эми ал Миланга өтөт деген ушак бар.

  16. I will right away clutch your rss as I can’t to
    find your e-mail subscription hyperlink or newsletter service.
    Do you have any? Kindly let me understand so that I may subscribe.
    Thanks.

  17. Sweet blog! I found it while surfing around on Yahoo News.
    Do you have any suggestions on how to get listed in Yahoo News?

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

  18. Good post. I learn something new and challenging on websites I stumbleupon on a daily basis.
    It’s always useful to read through content from other writers and practice something
    from other websites.

  19. โพสต์นี้ อ่านแล้วได้ความรู้เพิ่ม ค่ะ
    ผม เคยเห็นเนื้อหาในแนวเดียวกันเกี่ยวกับ เนื้อหาในแนวเดียวกัน
    ลองเข้าไปอ่านได้ที่
    Hamish
    ลองแวะไปดู
    เพราะอธิบายไว้ละเอียด
    ขอบคุณที่แชร์ สิ่งที่มีคุณค่า นี้

    และหวังว่าจะมีข้อมูลใหม่ๆ มาแบ่งปันอีก

  20. Great post. I was checking constantly this blog and I am impressed!
    Extremely helpful information particularly the last part :) I care for such info much.
    I was looking for this particular info for a long time.
    Thank you and best of luck.

  21. Thanks for a marvelous posting! I definitely enjoyed reading
    it, you can be a great author. I will always bookmark your blog and
    will eventually come back in the future. I want to encourage you to
    ultimately continue your great job, have a nice holiday weekend!

  22. Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out a lot.
    I hope to give something back and aid others like you aided
    me.

  23. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment
    is added I get three emails with the same comment. Is there any way you can remove me from that service?

    Many thanks!

  24. of course like your website but you have to test the spelling on several of
    your posts. Many of them are rife with spelling problems and
    I find it very bothersome to tell the reality then again I will certainly
    come again again.

  25. Whoa! This blog looks exactly like my old one!

    It’s on a entirely different topic but it has pretty much the same layout and design. Great choice of colors!

  26. Thanks for finally writing about > jQuery CDN as A Named Module In RequireJS | freestyle developments < Loved it!

  27. What i don’t realize is in truth how you’re not really much
    more neatly-preferred than you may be right now.

    You’re so intelligent. You already know thus significantly in the
    case of this topic, produced me personally consider it from
    so many varied angles. Its like women and men are not interested unless it is something
    to accomplish with Woman gaga! Your own stuffs nice. All the time
    care for it up!

  28. I have been surfing online more than 4 hours
    today, yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my view, if all website owners
    and bloggers made good content as you did, the internet will be a lot more
    useful than ever before.

  29. Heya i am for the first time here. I came across this board and I find It really useful &
    it helped me out a lot. I hope to give something back and aid others like you aided me.

  30. When I initially commented I appear to have clicked
    the -Notify me when new comments are added- checkbox and now whenever a comment is added I get 4
    emails with the exact same comment. Perhaps there is a means you can remove me from that service?
    Thank you!

  31. I love what you guys tend to be up too. This kind of clever work and exposure!

    Keep up the great works guys I’ve included you guys to blogroll.

  32. We are a group of volunteers and opening a new scheme in our community.
    Your site provided us with valuable info to work on. You have done an impressive job and our entire community
    will be thankful to you.

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>