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. What’s Happening i’m new to this, I stumbled upon this I have found It absolutely useful and it has helped me out loads.
    I hope to give a contribution & aid different customers like
    its helped me. Good job.

  2. Its like you learn my thoughts! You appear to grasp so much approximately this, such as you
    wrote the ebook in it or something. I feel
    that you could do with a few percent to pressure the message house a bit, but other than that, that is great blog.
    An excellent read. I will definitely be back.

  3. 88AA khẳng định vị thế bằng hệ thống pháp lý minh bạch và link truy cập chính thức an toàn. Trang chủ luôn được cập nhật mới, hạn chế tối đa tình trạng gián đoạn để hội viên yên tâm trải nghiệm.

    Với công nghệ bảo mật cao cùng kho trò
    chơi phong phú, tất cả đã tạo nên môi trường cá cược trực
    tuyến uy tín; đáp ứng mọi nhu cầu giải
    trí cho người tham gia. https://epsilon.eu.com/

  4. This piece of writing provides clear idea in favor of the new visitors of
    blogging, that actually how to do blogging and site-building.

  5. Hey there! This is kind of off topic but I need some guidance
    from an established blog. Is it hard to set up
    your own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about making my own but I’m not sure where
    to start. Do you have any ideas or suggestions? Many thanks

  6. 이것은 말 그대로 휴대폰 소액결제 서비스를 통해 얻은 상품이나 상품권을 현금으로 바꾸는 것을 의미합니다.
    예를 들어 휴대폰 소액결제 한도로
    문화상품권, 구글 기프트

  7. Ahaa, its fastidious conversation on the topic of this article at this place at this webpage, I have read all
    that, so now me also commenting at this place.