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

  1. Hello There. I found your blog using msn. This is a very well written article.

    I’ll make sure to bookmark it and return to read more of your useful info.
    Thanks for the post. I will definitely return.

  2. Howdy! Do you know if they make any plugins to protect against hackers?

    I’m kinda paranoid about losing everything I’ve worked hard on.
    Any suggestions?

  3. The other day, while I was at work, my cousin stole my apple ipad and tested
    to see if it can survive a thirty foot drop, just so she can be a youtube sensation. My iPad is now broken and she has
    83 views. I know this is totally off topic but I had to share it with someone!

  4. Oh my goodness! Awesome article dude! Thanks,
    However I am having issues with your RSS. I don’t know why I cannot subscribe to it.
    Is there anybody getting similar RSS problems? Anyone that knows the answer can you kindly respond?
    Thanx!!

  5. I think what you said made a lot of sense. But, what about this?
    suppose you were to create a awesome post title?
    I ain’t suggesting your content isn’t solid., but what
    if you added a title that makes people want more?

    I mean jQuery CDN as A Named Module In RequireJS | freestyle developments is a little vanilla.
    You might look at Yahoo’s home page and see how they create
    news headlines to grab viewers interested. You might add a video or a related picture or two
    to grab readers interested about what you’ve got to say.
    Just my opinion, it would bring your posts a little livelier.

  6. Hello there, I discovered your blog by the use of
    Google even as searching for a similar matter, your
    website came up, it seems to be great. I have bookmarked it in my google bookmarks.

    Hello there, simply became alert to your weblog thru Google,
    and located that it is truly informative. I’m going
    to watch out for brussels. I will be grateful should you proceed this in future.

    Many other folks will be benefited from your writing. Cheers!

  7. Hello, i feel that i saw you visited my weblog
    thus i got here to go back the prefer?.I am attempting to find things to enhance my
    site!I suppose its good enough to use some of your ideas!!

  8. What’s up to every one, the contents existing at this site are in fact
    awesome for people knowledge, well, keep up the nice work fellows.

  9. I need to to thank you for this very good read!!
    I absolutely loved every bit of it. I’ve got you book-marked
    to check out new things you post…

  10. 이것은 말 그대로 휴대폰 소액결제 서비스를
    통해 얻은 상품이나 상품권을 현금으로 바꾸는 것을 의미합니다.

    예를 들어 휴대폰 소액결제 한도로 문화상품권, 구글 기프트

  11. What’s Going down i am new to this, I stumbled upon this I have found It positively useful and it has aided me out
    loads. I am hoping to give a contribution &
    assist other users like its helped me. Good job.

  12. I’m not sure why but this website is loading
    extremely slow for me. Is anyone else having this issue or is it a issue on my end?
    I’ll check back later and see if the problem still exists.

  13. It’s really a nice and helpful piece of information. I’m happy that you shared this helpful
    info with us. Please stay us informed like this.
    Thanks for sharing.

  14. Hi! This is my 1st comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading your articles.

    Can you recommend any other blogs/websites/forums that go over the same topics?

    Thanks a ton!

  15. Yesterday, while I was at work, my sister stole my apple ipad
    and tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views.

    I know this is totally off topic but I had to share it with someone!

  16. Hi, I do think this is a great site. I stumbledupon it ;) I
    will revisit once again since I book marked it. Money and freedom
    is the best way to change, may you be rich and continue to
    guide others.

  17. Hey There. I found your blog using msn. This is a very neatly
    written article. I will make sure to bookmark
    it and come back to read extra of your useful information. Thank you for the post.

    I’ll certainly return.

  18. Hi, I do believe this is an excellent site.

    I stumbledupon it ;) I’m going to revisit yet again since i have saved
    as a favorite it. Money and freedom is the best way to change,
    may you be rich and continue to guide other people.

  19. You ought to take part in a contest for one of the highest quality sites on the web.
    I will highly recommend this web site!

  20. It’s amazing to go to see this web site and reading the views of all friends concerning this paragraph, while I am also eager of getting knowledge.

  21. of course like your website but you have to check the spelling on quite
    a few of your posts. Several of them are rife with
    spelling problems and I in finding it very troublesome to
    tell the reality nevertheless I will surely come back
    again.

  22. My brother recommended I might like this website. He was entirely right.
    This submit truly made my day. You cann’t believe simply how a lot time I had spent for this information! Thanks!

  23. I like the helpful information you provide for your articles.
    I’ll bookmark your blog and check once more right here frequently.
    I’m relatively sure I will be informed lots of new stuff right here!

    Best of luck for the next!

  24. Genuinely no matter if someone doesn’t be aware of after that its
    up to other viewers that they will help,
    so here it takes place.

  25. Everyone loves what you guys are up too. This type of clever work
    and coverage! Keep up the good works guys I’ve
    included you guys to my blogroll.

  26. I blog frequently and I genuinely appreciate your
    content. This great article has truly peaked my interest.

    I’m going to take a note of your blog and
    keep checking for new details about once per week. I opted in for your RSS feed too.

  27. It’s fantastic that you are getting ideas from this paragraph as well as from
    our discussion made here.

  28. Greate pieces. Keep writing such kind of information on your page.
    Im really impressed by it.
    Hi there, You’ve performed an excellent job.
    I will definitely digg it and in my view recommend
    to my friends. I am confident they’ll be benefited from this web site.

  29. Can I just say what a comfort to find someone that truly knows
    what they’re discussing on the net. You certainly understand how to bring an issue to light and make it
    important. More and more people ought to look at this and understand this side of
    the story. I was surprised that you aren’t more
    popular given that you certainly possess the gift.

  30. I’m not that much of a online reader to be honest but your sites really
    nice, keep it up! I’ll go ahead and bookmark your website to come back in the future.
    Cheers

  31. What i don’t understood is in truth how you are not
    really a lot more well-preferred than you might be right now.
    You are very intelligent. You understand therefore significantly relating to this subject, made me personally consider it from numerous varied angles.
    Its like women and men aren’t fascinated except it is something to do
    with Woman gaga! Your personal stuffs outstanding.

    At all times deal with it up!

  32. Hiya very cool site!! Man .. Beautiful .. Wonderful ..
    I’ll bookmark your web site and take the feeds additionally?

    I’m glad to seek out so many helpful information right here in the post, we need develop more strategies on this regard,
    thanks for sharing. . . . . .

  33. Good day! Would you mind if I share your blog with my myspace group?
    There’s a lot of people that I think would really appreciate your content.

    Please let me know. Thank you

  34. Hey there! I’ve been reading your site for a while now and finally got the courage to go ahead and give you a shout out from Kingwood Texas!

    Just wanted to tell you keep up the fantastic work!

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>