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.

2,209 thoughts on “jQuery CDN as A Named Module In RequireJS

  1. The appeal argued that electoral bonds are
    “completely traceable,” as evidenced by SBI’s secret number-based record of bond buyers and the political parties to which
    they give.

  2. Spot on with this write-up, I actually feel this site
    needs a great deal more attention. I’ll probably be back again to read through more, thanks for
    the info!

  3. Wow that was unusual. I just wrote an very long comment but after I clicked submit my comment didn’t show up.
    Grrrr… well I’m not writing all that over again. Regardless, just wanted to say superb blog!

  4. Ahaa, its nice dialogue on the topic of this piece
    of writing at this place at this web site, I have read all that, so
    now me also commenting at this place.

  5. Good day! I know this is kinda off topic however , I’d figured
    I’d ask. Would you be interested in exchanging links or maybe guest writing a blog article or vice-versa?
    My website goes over a lot of the same subjects as yours and I believe we could greatly benefit from each other.
    If you’re interested feel free to send me an email. I look
    forward to hearing from you! Awesome blog by the way!

  6. Hi there this is kind of of off topic but I was wanting to
    know if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

  7. Рабочая URL для Kraken сайта

    Kraken — популярный сервис в сети Tor с трастовыми селекторами и простым функционалом.

    Мы публикуем только проверенные ссылки, чтобы дать постоянный и быстрый подключение в любое время.

  8. Everything is very open with a precise clarification of the issues.
    It was really informative. Your website is very useful. Thank
    you for sharing!

  9. Hi there would you mind stating which blog platform you’re working
    with? I’m going to start my own blog soon but I’m having a difficult time
    selecting between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design seems different then most
    blogs and I’m looking for something unique. P.S Sorry for being off-topic but I had to ask!

  10. First of all I would like to say excellent blog! I had
    a quick question in which I’d like to ask if you don’t mind.
    I was interested to know how you center yourself and clear your head before writing.

    I have had a tough time clearing my mind in getting my ideas out.
    I truly do enjoy writing however it just seems like the first 10 to 15 minutes are
    generally lost simply just trying to figure out how to begin. Any ideas or tips?
    Thanks!

  11. What’s up to every one, the contents present at this web site are really amazing
    for people experience, well, keep up the nice work fellows.

  12. I really like your blog.. very nice colors & theme. Did you
    design this website yourself or did you hire someone to do it
    for you? Plz reply as I’m looking to construct my own blog
    and would like to know where u got this from. thank you

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

  14. Hi, I do believe this is a great web site. I stumbledupon it ;)
    I’m going to return once again since i have bookmarked it.
    Money and freedom is the greatest way to change, may you be rich and
    continue to guide others.

  15. I have read a few just right stuff here. Certainly price bookmarking for revisiting.
    I wonder how so much attempt you place to make the sort
    of great informative site.

  16. Terrific work! That is the type of information that should be shared
    across the web. Shame on the search engines
    for now not positioning this publish upper!

    Come on over and consult with my web site . Thank you =)

  17. I’m really impressed with your writing skills as
    well as with the layout on your blog. Is this a paid theme or did you modify
    it yourself? Either way keep up the nice quality writing, it’s rare to see a great blog like this one today.

  18. I do not know if it’s just me or if everyone else experiencing problems with your site. It appears as if some of the written text within your content are running off the screen. Can someone else please comment and let me know if this is happening to them too? This could be a issue with my web browser because I’ve had this happen previously. Thanks

    Also visit my page … https://totebags.ae/

  19. Hello there, You’ve done a great job. I will definitely
    digg it and personally recommend to my friends. I am confident they
    will be benefited from this website.

  20. Outstanding post however , 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 further.
    Thank you!

  21. For most up-to-date information you have to pay a visit the web and on world-wide-web I found this
    site as a best web page for newest updates.

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

  23. Hi this is kinda of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I wanted to get advice from someone
    with experience. Any help would be greatly appreciated!

  24. Great article! That is the type of information that should
    be shared around the net. Disgrace on the search engines for not positioning this post
    higher! Come on over and visit my web site . Thank you =)

  25. Hello there! This post could not be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept chatting about this. I will forward this page to him.
    Pretty sure he will have a good read. Thanks for sharing!

  26. Hi there, I discovered your blog by means of Google whilst looking for a
    similar topic, your website came up, it appears to
    be like great. I’ve bookmarked it in my google bookmarks.

    Hello there, just became aware of your blog through Google, and located that it’s
    really informative. I am gonna watch out for brussels.
    I will be grateful if you happen to proceed this in future.
    A lot of folks will probably be benefited from your writing.
    Cheers!

  27. Hello there! Quick question that’s entirely off topic. Do you know how to make your
    site mobile friendly? My weblog looks weird when browsing from my iphone.
    I’m trying to find a template or plugin that might be able to
    resolve this problem. If you have any suggestions,
    please share. With thanks!

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>