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 loved as much as you’ll receive carried out right here. The sketch
    is tasteful, your authored subject matter stylish. nonetheless, you command get bought an shakiness over that
    you wish be delivering the following. unwell unquestionably come more formerly
    again as exactly the same nearly a lot often inside case you shield this increase.

  2. Spot on with this write-up, I seriously believe that this site needs a great deal more attention. I’ll probably
    be returning to read more, thanks for the info!

    Here is my web page; zkreciul01

  3. A fascinating discussion is definitely worth
    comment. There’s no doubt that that you need
    to publish more on this issue, it might not be a taboo subject but usually folks
    don’t talk about such topics. To the next! Cheers!!

  4. Hello there! I simply want to give you a huge thumbs
    up for the great information you have right here on this post.
    I’ll be returning to your site for more soon.

  5. Hello, I think your blog might be having browser compatibility issues.
    When I look at your website in Safari, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up! Other then that,
    very good blog!

  6. It’s really a great and useful piece of information. I’m satisfied that you just shared
    this helpful information with us. Please stay us up to date
    like this. Thanks for sharing.

  7. Hi, Neat post. There is a problem together with your site in internet explorer, might check this?
    IE nonetheless is the market chief and a large element of other
    people will leave out your excellent writing due to this problem.

  8. Excellent beat ! I wish to apprentice whilst you amend your website, how can i subscribe for a weblog web site?
    The account helped me a appropriate deal. I have been tiny bit
    familiar of this your broadcast offered vivid clear idea

  9. hello there and thank you for your info – I’ve definitely picked up anything new from right here.

    I did however expertise a few technical points using this web site, since I experienced to reload
    the site lots of times previous to I could get it to load properly.
    I had been wondering if your web host is OK?
    Not that I’m complaining, but slow loading instances times will often affect
    your placement in google and could damage your
    quality score if ads and marketing with Adwords.

    Anyway I’m adding this RSS to my email and can look out for a lot more of your respective fascinating content.
    Make sure you update this again very soon.

  10. รับทำ seo, seo, ทำseo, รับทํา seo, seo
    google, seo ย่อมาจาก, seo sem คือ, seo sem,
    เอเจนซี่ seo, seo agency, รับทํา seo ราคา,
    seo กับ sem, ทําseo ราคา, ทําseo youtube, ทําseo
    facebook, seo ทํายังไง, รับทํา seo facebook, seo ราคาถูก, บริษัทรับทํา
    seo

  11. Hi there are using WordPress for your blog platform?
    I’m new to the blog world but I’m trying to
    get started and set up my own. Do you need any
    coding knowledge to make your own blog? Any help
    would be really appreciated!

  12. Thanks for the auspicious writeup. It actually used to be a entertainment
    account it. Look advanced to more introduced agreeable from you!
    However, how could we be in contact?

  13. Hmm is anyone else having problems with the images on this blog
    loading? I’m trying to figure out if its a problem on my end or if it’s the blog.
    Any feed-back would be greatly appreciated.

  14. You’re so cool! I do not suppose I’ve truly read a single thing like that before.
    So good to discover someone with some genuine thoughts on this
    subject. Seriously.. many thanks for starting this up.
    This web site is one thing that is required on the
    web, someone with some originality!

  15. Its such as you learn my thoughts! You appear to understand a
    lot about this, such as you wrote the guide in it or something.

    I believe that you could do with a few p.c. to pressure the message home
    a little bit, however instead of that, this is wonderful blog.
    A great read. I will definitely be back.

  16. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot
    you an e-mail. I’ve got some suggestions for your blog you might be interested in hearing.
    Either way, great site and I look forward to seeing it improve
    over time.

  17. I am really loving the theme/design of your weblog.
    Do you ever run into any browser compatibility issues?

    A small number of my blog readers have complained about my website not working correctly in Explorer
    but looks great in Safari. Do you have any suggestions to help fix this problem?

  18. I know this if off topic but I’m looking into starting my own weblog
    and was curious what all is required to get set
    up? I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web savvy so I’m not 100% certain. Any recommendations or advice would be greatly appreciated.
    Appreciate it

  19. Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something.
    I think that you could do with some pics to drive the
    message home a bit, but instead of that, this is wonderful blog.

    An excellent read. I will definitely be back.

  20. Hello Dear, are you truly visiting this site regularly, if so then you will
    definitely take fastidious knowledge.

  21. Great post but I was wondering if you could write a litte
    more on this topic? I’d be very thankful if you could elaborate a
    little bit more. Thank you!

  22. I am not sure where you are getting your information, but good topic.

    I needs to spend some time learning much more or understanding more.

    Thanks for magnificent information I was looking
    for this info for my mission.

  23. It’s really a nice and helpful piece of information. I am happy that you
    simply shared this helpful information with us. Please keep us
    up to date like this. Thanks for sharing.

  24. I’m really enjoying the design and layout of your site.

    It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme?
    Great work!

  25. I feel this is one of the so much important info
    for me. And i am happy reading your article. However wanna remark on few general things, The
    site taste is wonderful, the articles is truly great : D.
    Just right task, cheers

  26. What i do not understood is in truth how you’re no longer really much more smartly-liked
    than you might be right now. You are so intelligent. You realize thus considerably in terms of
    this subject, made me in my view consider it from so many numerous
    angles. Its like men and women are not involved until
    it is something to accomplish with Woman gaga!
    Your own stuffs excellent. At all times care for it up!

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>