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. wonderful post, very informative. I wonder why the opposite experts of this sector
    do not realize this. You must continue your writing.
    I am sure, you’ve a great readers’ base already!

  2. If you wish for to grow your knowledge just keep visiting this site and be updated with the latest news
    update posted here.

  3. Artikel ini patut diapresiasi karena mampu menggabungkan berbagai topik menarik seperti Situs Mix Parlay, Situs Parlay Gacor, dan Situs Judi Bola tanpa terasa berlebihan.

    Penulis juga menempatkan pembahasan KUBET serta toto macau dengan sangat seimbang.

    Informasi tentang kubet login dan situs parlay menambah nilai bagi
    pembaca yang mencari sumber terpercaya.

  4. DAGA 88 대한민국에 오신 것을 환영합니다
    – 당신의 승리, 전액 지급. 지금 바로 매력적인 보너스를 받고, 최고의 게임을 즐기며, 믿을 수 있고 편리한 온라인 베팅 경험을 시작하세요!

  5. Can I simply just say what a comfort to uncover someone that actually understands what they are talking
    about on the net. You definitely know how to bring an issue to light and make
    it important. More people have to look at this and understand this side of the story.

    I was surprised that you’re not more popular since you most certainly have the gift.

  6. I really like what you guys are usually up too.
    This sort of clever work and reporting! Keep up the great works guys I’ve added you
    guys to my own blogroll.

  7. I think the admin of this web page is really working hard in support of his website, because here every material is
    quality based data.

  8. You have made some really good points there. I
    looked on the net to find out more about the issue and found most people will go along with your views on this site.

  9. Having read this I believed it was very enlightening.

    I appreciate you finding the time and effort to put
    this short article together. I once again find myself
    spending way too much time both reading and leaving comments.
    But so what, it was still worthwhile!

  10. Can I just say what a relief to uncover a person that genuinely knows what they’re
    talking about on the net. You definitely understand how
    to bring an issue to light and make it important.
    More and more people must look at this and understand this side of the story.

    I was surprised that you’re not more popular given that you definitely possess the gift.

  11. Yesterday, while I was at work, my cousin stole my iphone and tested to see
    if it can survive a 40 foot drop, just so she can be
    a youtube sensation. My apple ipad is now destroyed and
    she has 83 views. I know this is totally off topic but I had to share it with someone!

  12. I was recommended this blog by my cousin. I’m not sure whether this post is written by him
    as no one else know such detailed about my problem.
    You are amazing! Thanks!

  13. Hmm is anyone else having problems with the images on this blog loading?

    I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any suggestions would be greatly appreciated.

  14. Wow, amazing blog format! How long have you been running a blog for?
    you made blogging look easy. The entire look of your site is wonderful, let alone the content!

  15. I’m amazed, I have to admit. Rarely do I encounter a blog that’s both educative and entertaining, and let me tell you, you’ve
    hit the nail on the head. The problem is an issue that not enough men and women are speaking intelligently about.
    I am very happy that I found this during my search for something regarding this.

  16. I was recommended this web site by my cousin. I’m not sure whether
    this post is written by him as nobody else know such detailed about my problem.
    You are wonderful! Thanks!