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,262 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. Excellent blog right here! Additionally your web site a lot up fast!

    What host are you the use of? Can I get your affiliate hyperlink to
    your host? I desire my web site loaded up as fast as yours lol

  2. Been through enough exchanges in the US to have a solid feel for the reality vs. the marketing gloss. First off, fees are where most platforms get you if you’re not careful Learn more

  3. Great blog! Do you have any recommendations for aspiring writers?
    I’m hoping to start my own site soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress or go
    for a paid option? There are so many options out there that I’m completely confused
    .. Any suggestions? Bless you!

  4. I’ve been exploring for a little for any high quality articles or weblog posts on this kind of house .
    Exploring in Yahoo I finally stumbled upon this web site.
    Studying this info So i’m happy to convey that I’ve a very just right uncanny
    feeling I came upon exactly what I needed. I most surely will make certain to do not overlook this website and give it a glance on a continuing basis.

  5. This design is wicked! You most certainly know how to keep
    a reader amused. Between your wit and your videos, I was
    almost moved to start my own blog (well, almost…HaHa!)
    Fantastic job. I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  6. My friends still talk about last year’s experience; if you haven’t tried bringing one along yet then don’t hesitate booking ahead soon!”          #   #   Anykeyword   bounce.house.rental

  7. Thank you a lot for sharing this with all people you really recognise what you’re speaking approximately!
    Bookmarked. Please also talk over with my web site =). We will have a link alternate agreement among us

  8. Customer reviews often direct my options when buying electronics. It’s always smart to hear from others before buying. For trusted feedback, consider visiting free phones !

  9. I have read so man posts on thee topic of
    the blogger lovers but this paragraph is
    genuinely a good post, keep it up.

  10. whoah this blog is wonderful i love reading your articles.

    Stay up the great work! You realize, lots of persons are searching round for this info, you
    can help them greatly.

  11. I do consider all the concepts you have introduced in your post.
    They are very convincing and can definitely work.
    Still, the posts are very brief for starters. Could you please lengthen them a little from subsequent time?

    Thank you for the post.

  12. I definitely like how jewelry can change a whole attire! It’s fantastic how a simple piece can add a lot beauty and character. Have you ever thought of tailoring your own fashion jewelry? It can produce a truly special statement piece buy gold denver

  13. This paragraph provides clear idea designed for the new people of
    blogging, that in fact how to do blogging.

  14. Woah! I’m really enjoying the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between user friendliness and appearance.

    I must say you have done a very good job with this. Also, the
    blog loads very fast for me on Chrome. Superb Blog!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>