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 think this is one of the most vital information for me.

    And i’m glad reading your article. But wanna remark on few general
    things, The website style is ideal, the articles is
    really excellent : D. Good job, cheers

  2. Кто сейчас фактически рассчитывается за
    границей в ₽?
    Давно хотел спросить, как вы это организовали —
    везде стоп и фрод.

    Вы гоните через китай или уже нашли
    какой-то свежий вариант?

    На всякий живой кейс:
    есть кнопка, которая принимает ₽ и выдаёт валюту
    за границей.
    Без звонков от банка.

    Если надо — поделюсь контактом —
    просто отметься тут.
    Сняло вопрос в 2 клика.

    Отвечу в треде.

    Here is my homepage; Криптокошелёк

  3. This is really fascinating, You are an excessively professional blogger.
    I have joined your feed and sit up for searching
    for extra of your wonderful post. Also, I have shared your website in my social networks

  4. Great beat ! I wish to apprentice while you amend your web site, how can i subscribe for a
    blog website? The account aided me a acceptable deal.
    I had been a little bit acquainted of this your broadcast provided bright clear idea

  5. What i do not understood is in fact how you are no longer really
    a lot more smartly-liked than you might be right now.

    You’re so intelligent. You know thus considerably in relation to this topic, made me in my opinion believe it from a lot of various angles.
    Its like men and women aren’t interested until it is something to accomplish with Lady gaga!

    Your personal stuffs outstanding. At all times handle it up!

  6. Wow! This blog looks just like my old one! It’s on a completely different subject but it has pretty much the same layout and design. Excellent choice of colors!

  7. If you’re thinking about a cooking area remodel, don’t undervalue the power of great lighting! I found some amazing lighting choices on kitchen remodel that I can not wait to carry out.

  8. Hurrah! Finally I got a webpage from where I be able to truly obtain helpful
    information regarding my study and knowledge.

  9. I like the valuable information you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I’m quite certain I will learn lots of new stuff right here!
    Good luck for the next!

  10. 1. Also, mal ehrlich, meine Kleine hat auch oft solche roten Flecken, und ich hab erst gedacht, das sind Insektenstiche oder so. Eine Ärztin hat dann aber gesagt, es könnte eine Allergie sein, weil sie auch oft juckt und sich kratzt Klicken Sie hier für mehr

  11. Kijk, ik ben zelf in CRUKS geregistreerd en mis het af en toe wel echt om te gokken. Maar ik vraag me af: zijn die MGA-casino’s zonder CRUKS-check echt wel zo veilig als ze zeggen? Ik voel me soms een beetje huiverig zonder die extra bescherming veiligheid met SSL technologie