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. 남양주출장마사지 – 남양주 전역에 24시간 여성 전문 마사지사가
    찾아가는 출장 홈타이 서비스! 아로마,
    스포츠, 커플 마사지로 피로와 스트레스를 합리적 가격에 풀어

  2. Appreciating the hard work you put into your website and detailed information you
    offer. It’s great to come across a blog every
    once in a while that isn’t the same old rehashed material. Fantastic
    read! I’ve bookmarked your site and I’m including
    your RSS feeds to my Google account.

  3. Very quickly this web site will be famous among
    all blog viewers, due to it’s fastidious articles

  4. You really make it seem so easy with your presentation but I find this matter to be really something that
    I think I would never understand. It seems too complicated and extremely broad for me.

    I am looking forward for your next post, I will try to get the hang of
    it!

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

  6. I was recommended this website via my cousin. I am not certain whether this
    publish is written by him as no one else realize such distinctive approximately my difficulty.
    You’re amazing! Thank you!

  7. Great goods from you, man. I’ve understand your stuff previous to and
    you’re just extremely great. I actually like what you have acquired here,
    really like what you are saying and the way in which you say it.
    You make it entertaining and you still care for to keep
    it sensible. I can’t wait to read far more from you.
    This is actually a terrific web site.

  8. Good day! This is my first visit to your blog! We are a group of volunteers and starting a new
    project in a community in the same niche. Your blog provided us beneficial information to work on. You have done a extraordinary job!

  9. Awesome blog! Do you have any suggestions for aspiring writers?

    I’m hoping to start my own site soon but I’m a little lost on everything.

    Would you advise starting with a free platform like WordPress or go for a paid option? There are so many options out there
    that I’m totally overwhelmed .. Any ideas? Thank you!

  10. Having tried a handful of US-based crypto exchanges, the biggest eye-opener isn’t the token selection or interface—it’s the fees and support that genuinely make or break the experience https://occ12.mssg.me/

  11. I’ve been surfing online more than three hours today, yet I never
    found any interesting article like yours.
    It is pretty worth enough for me. Personally, if all web owners and bloggers
    made good content as you did, the web will be a lot more useful than ever before.

  12. I know this if off topic but I’m looking into starting my own weblog and
    was curious what all is required to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% sure.
    Any suggestions or advice would be greatly appreciated.

    Thank you

  13. Generally I don’t read post on blogs, but I
    wish to say that this write-up very forced me to try
    and do it! Your writing taste has been amazed me.
    Thanks, quite great article.