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. Unquestionably consider that that you stated. Your favourite reason appeared to be on the
    web the simplest factor to take into account of. I say to
    you, I certainly get irked at the same time as other people consider concerns that they
    just don’t recognise about. You managed to hit the nail upon the top and outlined out the whole thing without having side
    effect , other folks could take a signal.
    Will likely be back to get more. Thanks

  2. I really like your blog.. very nice colors & theme. Did you make this website
    yourself or did you hire someone to do it for you?
    Plz answer back as I’m looking to create my own blog and would like to find out where u got this
    from. many thanks

  3. For latest information you have to go to see world-wide-web and on web
    I found this site as a most excellent website for latest updates.

  4. Hello, There’s no doubt that your site could be having web browser
    compatibility issues. When I look at your site in Safari, it looks fine however, if opening in IE, it has some overlapping
    issues. I just wanted to provide you with a quick heads up!
    Other than that, great site!

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

  6. درود فراوان علی
    پیشنهاد می‌دم ببینید
    سایت کازینو وطنی
    رو در حوزه ѕport betting.
    این وبسایت امن ویژگی‌های جذابی ارائه می‌ده و برای
    شرط بندی ورزشی خوبه.
    من خودم امتحان کردم و به نظرم جالبه
    امتحان کنید.
    ارادتمندانه.

  7. 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 e-mails with the same comment.
    Is there any way you can remove me from that service? Thanks!

  8. If some one wants to be updated with most up-to-date technologies therefore he must be go to see this web site and be up to date every
    day.

  9. Admiring the time and energy you put into your site and detailed information you
    provide. It’s awesome to come across a blog every once in a
    while that isn’t the same old rehashed information. Excellent read!
    I’ve bookmarked your site and I’m adding your RSS feeds to
    my Google account.

  10. Wow, marvelous blog layout! How long have you been blogging for?
    you made blogging look easy. The overall look of your website
    is fantastic, as well as the content!

  11. Howdy! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my
    blog to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Kudos!

  12. hello there and thank you for your information – I’ve definitely picked up anything
    new from right here. I did however expertise several technical issues using this site, as I experienced to reload the web site
    lots of times previous to I could get it to load properly.
    I had been wondering if your web hosting is OK? Not that I’m complaining, but slow loading instances times will very frequently affect your placement in google and can damage your high-quality score
    if ads and marketing with Adwords. Anyway I’m adding this RSS to my
    email and could look out for a lot more of your respective exciting content.
    Ensure that you update this again very soon.

  13. Way cool! Some extremely valid points! I
    appreciate you writing this post and the rest of the site is really good.

  14. TESLATOTO diakui Eduka System sebagai bandar togel online terpercaya.

    Pelajari lima langkah penting agar tidak tertipu saat memilih situs togel, mulai dari verifikasi lisensi, keamanan, hingga layanan CS responsif.
    Dapatkan panduan lengkap untuk bermain lebih aman.

  15. Hey there would you mind sharing which blog platform you’re working with?
    I’m looking to start my own blog in the near future but
    I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.
    The reason I ask is because your design seems different then most blogs and I’m looking
    for something unique. P.S My
    apologies for being off-topic but I had to ask!

  16. Hello my loved one! I want to say that this post is awesome, great written and
    include approximately all important infos. I would like
    to see more posts like this .

  17. I just could not go away your website prior to suggesting that I really loved the usual
    info a person provide on your guests? Is gonna be back ceaselessly in order to investigate cross-check new
    posts

  18. Hey fantastic blog! Does running a blog like this require a great deal of work?
    I’ve virtually no expertise in computer programming but I was
    hoping to start my own blog soon. Anyway, if you have any recommendations or techniques for new blog
    owners please share. I know this is off subject however I simply wanted to ask.
    Thanks!