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’m really impressed with your writing talents and also with the format to
    your blog. Is this a paid subject matter or did you modify it yourself?
    Either way keep up the excellent quality writing, it’s
    rare to look a nice blog like this one nowadays..

  2. I don’t know whether it’s just me or if perhaps everyone else experiencing issues with your site.

    It looks like some of the text on your content are running
    off the screen. Can someone else please provide feedback and let me know if this
    is happening to them as well? This might be a problem with my internet browser because I’ve had this happen before.
    Thanks

  3. We’re a gaggle of volunteers and starting a new scheme in our community.
    Your site offered us with valuable information to work on.
    You’ve performed an impressive task and our entire group
    might be thankful to you.

  4. Great blog! Is your theme custom made or did you download
    it from somewhere? A design like yours with a few simple tweeks would really make my blog shine.
    Please let me know where you got your theme.
    Appreciate it

  5. Thanks for your marvelous posting! I quite enjoyed reading it, you might be a great author.

    I will ensure that I bookmark your blog and will come back down the road.
    I want to encourage you to continue your great writing, have a nice afternoon!

  6. A short while ago tried this website to convert my BTC for stablecoin on TRC-20.

    From my own experience, it worked flawlessly.

    I was really impressed how quick the process was.
    Previously, I also experimented with Dogecoin to USDC pairs with
    the same service. Every trade went through very efficiently.
    My favorite thing about it is the instant rate updates.
    No surprise deductions — everything was clear and fair.

    The trading panel was intuitive, and even someone new to crypto could complete the trade without help.
    Additionally, security measures gave me confidence. They respected privacy, yet
    the process remained safe.
    The only downside was that customer service took some time.

    It’s not a deal-breaker, however more active support
    staff would make the platform even more complete.

    Besides that, the final outcome was great. my balance updated almost
    instantly. For that reason, I strongly suggest other crypto traders to follow this platform
    and go through the full review about different cryptocurrency pairs.

    If you’re wondering in doing fast crypto swaps, this service should be on your
    list. It supports ETH, USDC, DOGE, TRX, and more.

    All in all, my overall impression was satisfying. Fast speed, low fees, simple design, and reliable swaps.
    I’ll come back again for my future crypto conversions.
    Check it now! Learn more on their official blog — it’s totally worth reading.

  7. I do not even know how I ended up here, but I thought this post
    was great. I don’t know who you are but certainly you’re going
    to a famous blogger if you aren’t already ;) Cheers!

  8. Tһanks for the gooɗ writeup. It in reality սsed to be a enjoyment account іt.
    Glance complicated tо moгe delivered agreeable from y᧐u!
    By the way, hoow coᥙld wе keep up a correspondence?

    Here іs my web site: Methodist Girls’ (Secondary) – Stanton,