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. With havin so much content do you ever run into any issues of plagorism
    or copyright infringement? My blog has a lot of completely unique
    content I’ve either written myself or outsourced but it
    looks like a lot of it is popping it up all over the internet without my authorization. Do you know any methods to help stop content from being ripped off?

    I’d truly appreciate it.

  2. You actually make it seem really easy along with your presentation however I find this topic to be really one thing that I
    feel I might never understand. It kind of feels too complex
    and very wide for me. I’m taking a look ahead for your subsequent submit,
    I will attempt to get the grasp of it!

  3. топ 10 взломанных игр на android — это замечательный способ
    получить новые возможности. Особенно если вы
    играете на Android, модификации открывают
    перед вами новые возможности.
    Я часто использую модифицированные версии игр, чтобы развиваться быстрее.

    Моды для игр дают невероятную свободу в игре, что погружение в игру гораздо
    интереснее. Играя с модификациями, я могу персонализировать свой опыт, что добавляет новые приключения и делает игру более непредсказуемой.

    Это действительно захватывающе, как такие моды могут улучшить
    переживания от игры, а при этом с максимальной безопасностью использовать такие взломанные
    версии можно без особых неприятных последствий, если быть внимательным и следить за обновлениями.

    Это делает каждый игровой процесс лучше контролируемым,
    а возможности практически широкие.

    Советую попробовать такие игры с модами для Android — это может придаст новый смысл

  4. It’s going to be end of mine day, however before end I am reading this great piece of writing to improve
    my knowledge.

  5. It is the best time to make some plans for the future and
    it’s time to be happy. I’ve read this post and if I could
    I desire to suggest you some interesting things or advice.
    Maybe you can write next articles referring to
    this article. I wish to read even more things about it!

  6. VIP memberships “Expired” but Online Access Still Has Unlimited Use.

    It’s confusing if this is an Problem/Defect or what, but essentially, any inactive paid account that still has the ability to use purchased content will show up as an “Inactive Membership”
    in the downloader.
    You will still be able to download all files, even if it expires, but you can still view/download it when logged in to the platform
    itself.
    BangBros Free Membership, Free BangBros Membership, Free BangBros Premium, Get BangBros Free Access,
    BangBros Premium Free Trial, Join BangBros for Free, BangBros Premium Account
    Free, Free BangBros Login, Unlock Free BangBros Membership, BangBros Free
    Premium Access.

  7. Great work! This is the kind of info that should be shared around the web.
    Shame on the search engines for no longer positioning this submit upper!
    Come on over and discuss with my website .
    Thanks =)