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. I recently experienced this website to swap my BTC to USDT
    on the TRON network. From my own experience, it went super smooth.

    It surprised me that the conversion took just a few minutes.

    Before this trade, I also experimented with BNB to ETH pairs through this
    exchange. Each swap was processed smoothly. I love the
    transparent rate system. No hidden fees — what you see is what you get.

    The interface is simple, and even a first-timer could manage
    the trade easily. Moreover, the security level felt reliable.
    Verification was minimal, while still the process remained safe.

    What I didn’t like was that customer service took
    some time. It didn’t ruin the experience, but more active support
    staff would make the experience even more complete.

    Besides that, the swap was successful. Funds appeared in my
    TRC-20 wallet. Due to my great experience,
    I highly encourage other crypto traders to visit
    this site and read the big article about fast conversions between coins.

    If you’re wondering in doing fast crypto swaps, this service is a great choice.

    You can also trade many other top coins.
    To conclude, my experience proved the site works great.
    This platform combines great rates and simplicity.

    I’ll come back again for my future crypto conversions. Go for it!
    Learn more on their official blog — it might change how you trade crypto.