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.

6,875 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. Get a free Edumail and temporary email instantly at EdumailFree.com.
    Enjoy a secure, fast, and anonymous email service perfect for students, professionals, and
    temporary use. No signup required!

  2. Thanks for some other wonderful post. Where else could anybody get that kind of info
    in such an ideal approach of writing? I have a presentation subsequent week,
    and I am on the search for such information.

  3. Oh my goodness! Awesome article dude! Many thanks, However
    I am experiencing difficulties with your RSS. I don’t understand
    why I can’t join it. Is there anybody getting identical RSS issues?
    Anybody who knows the solution can you kindly respond? Thanks!!

  4. Hello terrific website! Does running a blog like this take a large amount of work?
    I have very little expertise in coding however I had been hoping to start my own blog in the
    near future. Anyhow, should you have any ideas or tips for new blog owners
    please share. I understand this is off topic however I just
    needed to ask. Thank you!

  5. Woah! I’m really loving the template/theme of this website.
    It’s simple, yet effective. A lot of times
    it’s difficult to get that “perfect balance” between user friendliness
    and visual appeal. I must say that you’ve done a superb job with this.
    Additionally, the blog loads super quick for me on Chrome.
    Superb Blog!

  6. These are in fact impressive ideas in regarding blogging.
    You have touched some pleasant factors here. Any way keep up wrinting.

  7. I am extremely impressed along with your writing abilities
    and also with the layout on your weblog. Is that this a paid
    subject matter or did you modify it your self? Anyway keep up the nice
    high quality writing, it’s uncommon to look a nice weblog like
    this one these days..

  8. What’s up, this weekend is nice designed for me, for the reason that this point in time i am reading this great informative piece of
    writing here at my house.

  9. of course like your website but you need to check the spelling
    on several of your posts. A number of them are rife with spelling issues
    and I find it very bothersome to inform the reality however I’ll certainly come back again.

  10. I was more than happy to discover this page. I wanted to thank you for your time just for this fantastic
    read!! I definitely enjoyed every bit of it and
    i also have you saved to fav to check out new things on your web site.

  11. My brother suggested I might like this blog. He was
    totally right. This post actually made my day. You can not imagine just how much time I had spent for this
    information! Thanks!

  12. Its like you read my mind! You appear to know a lot about
    this, like you wrote the book in it or something.
    I think that you can do with some pics to drive the message
    home a bit, but instead of that, this is magnificent blog.
    A fantastic read. I’ll certainly be back.

  13. My partner and I absolutely love your blog and find many
    of your post’s to be what precisely I’m looking for.
    can you offer guest writers to write content in your case?
    I wouldn’t mind publishing a post or elaborating on some of the subjects
    you write concerning here. Again, awesome weblog!

  14. Thank you for the auspicious writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! However, how can we communicate?

  15. Hmm it appears like your blog ate my first comment (it was
    super long) so I guess I’ll just sum it up what I had written and say,
    I’m thoroughly enjoying your blog. I too am
    an aspiring blog blogger but I’m still new to everything.
    Do you have any tips for newbie blog writers?

    I’d certainly appreciate it.

  16. Excellent pieces. Keep posting such kind of information on your page.
    Im really impressed by your blog.
    Hi there, You’ve performed an incredible job.
    I’ll definitely digg it and for my part suggest to my
    friends. I am sure they will be benefited from
    this site.

  17. Good day! I simply want to offer you a huge thumbs up for your great information you have got right here on this post.
    I’ll be returning to your site for more soon.

  18. Nice post. I learn something new and challenging on websites I stumbleupon every day.
    It will always be interesting to read through content from other writers and use
    a little something from other websites.

  19. continuously i used to read smaller content which as well clear their motive, and that is also happening with this post which I am reading at this place.

  20. It’s a shame you don’t have a donate button! I’d definitely donate to
    this brilliant blog! I guess for now i’ll settle for book-marking and adding
    your RSS feed to my Google account. I look forward to fresh updates and will talk about
    this blog with my Facebook group. Talk soon!

  21. Excellent post. I was checking constantly this blog and I am impressed!
    Extremely useful information specifically the last part :
    ) I care for such info a lot. I was seeking this particular info for a long time.
    Thank you and best of luck.

  22. Hello would you mind letting me know which hosting company you’re using?
    I’ve loaded your blog in 3 completely different browsers and I
    must say this blog loads a lot faster then most. Can you suggest a good hosting provider at a honest price?
    Thanks a lot, I appreciate it!

  23. Heya! I just wanted to ask if you ever have any issues with hackers?

    My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no data
    backup. Do you have any methods to prevent hackers?

  24. Hi! I realize this is somewhat off-topic however I had to ask.

    Does building a well-established blog such as yours require a large
    amount of work? I’m brand new to writing a blog but I do write in my journal every day.
    I’d like to start a blog so I will be able to share my experience and views online.
    Please let me know if you have any suggestions or tips
    for brand new aspiring blog owners. Thankyou!

  25. Please let me know if you’re looking for a article author for your
    weblog. You have some really good posts and I feel I
    would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog
    in exchange for a link back to mine. Please blast me an e-mail if interested.
    Thank you!

  26. I simply couldn’t go away your website prior to suggesting that I actually enjoyed the
    standard info an individual supply to your guests?
    Is gonna be again ceaselessly in order to inspect new posts

  27. Hey there! Do you know if they make any plugins to assist with
    SEO? I’m trying to get my blog to rank for some targeted
    keywords but I’m not seeing very good results. If you know of any please share.
    Appreciate it!

  28. That is a very good tip especially to those fresh to the blogosphere.
    Short but very accurate info… Appreciate your sharing this one.
    A must read post!

  29. I’m curious to find out what blog system you have been utilizing?
    I’m having some minor security problems with my latest site and I would like to find
    something more risk-free. Do you have any recommendations?

  30. This is very attention-grabbing, You’re a very skilled
    blogger. I’ve joined your feed and look ahead to inn
    search of more of your fantastic post. Additionally, I have shared yor website inn my social
    networks

  31. Refresh Renovation Broomfield
    11001 W 120th Ave 400 suite 459ɑ,
    Broomfield, CO 80021, United Ⴝtates
    +13032681372
    Home easy makes refresh renovating үour (Indira)

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>