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. Allow me begin by stating this isn’t any kind of promotion. This is just a genuine personal
    story that I chose to share because it might help someone. Should you be battling with gambling or
    even noticing things getting out of hand, don’t scroll away just yet.

    I became someone who thought a little bet here and there couldn’t hurt.
    Initially, it felt like harmless fun—a blackjack game after work—nothing serious.

    But, it spiraled.
    Without realizing, I was checking odds more than my bank balance.
    I’d win sometimes, but those wins just made it deeper. I kept running after that high.
    One weekend, I lost nearly [insert loss amount here, e.g., "$2,000"] in less than two days.
    That was my kid’s school fees. And still, I went back the next day.

    What’s worse is how much I lied—my friends.
    I was embarrassed, and yet I kept doing it. If that sounds familiar, you know what I mean.
    Then I came across a particular article—and I’m not promoting it—but it made me stop and really
    think. I’m not claiming it’s a miracle fix, but it made me wake up I was in.
    The article wasn’t judgmental. It just spoke honestly
    in a way I’d never heard before. It explained how gambling
    is more than just a bad hobby, and how you’re playing
    against odds you can’t beat.
    That night, I accepted that I had a problem. And
    more importantly, that I needed to stop. It gave me tools that
    helped me take the initial move towards reclaiming my
    life.
    Since then, I’ve deleted every betting
    app I ever had. I’ve talked to my partner.

    It’s not easy. It’s still a fight sometimes.
    But I’m staying strong.
    If any of this sounds like your life, then take the time to read it.
    {

  2. Attractive section of content. I just stumbled
    upon your website and in accession capital to assert that I get in fact enjoyed account your blog posts.
    Anyway I will be subscribing to your augment and even I achievement you access consistently fast.

  3. Е2BET 대한민국에 오신 것을 환영합니다 – 당신의 승리, 전액 지급.

    매력적인 보너스를 즐기고, 재미있는 게임을 플레이하며, 공정하고 편안한 온라인 베팅 경험을 느껴보세요.
    지금 등록하세요!

  4. Very nice post. I simply stumbled upon your
    weblog and wished to mention that I’ve truly loved surfing around your weblog posts.

    After all I’ll be subscribing in your rss feed and I’m hoping you write once more soon!

  5. fantastic issues altogether, you simply gained a brand new reader.
    What may you recommend about your publish that you just made some days
    ago? Any positive?

  6. I have been xploring for a little bit for any high-quality articles or blog posts in this
    kind of house . Explloring in Yahoo I ultimately stumbled upon this web site.
    Studying this information So i am glad to show that I’ve an incredibly excellenjt uncanny feeling I discovdred just
    what I needed. I so much certainly will make sure tto don?t forget this website and give
    it a look regularly.

    My web page сервисный центр канди

  7. Marvelous, what a webpage it is! This website presents helpful information to us, keep it up.

  8. Nice post. I learn something new and challenging on websites I stumbleupon everyday.

    It’s always useful to read through content from other writers and use something from other web sites.

  9. What’s Happening i am new to this, I stumbled upon this
    I have found It positively helpful and it has aided me out loads.
    I’m hoping to give a contribution & help other users like its helped
    me. Great job.

  10. Every weekend i used to pay a quick visit this site, because i want
    enjoyment, for the reason that this this site conations really nice funny information too.

  11. If some one wishes to be updated with latest technologies therefore he must
    be pay a visit this web site and be up to date
    all the time.