January 16, 201214 yr Been messing about with a few wordpress boilerplates lately and now have Jquery loading in the footer via functions.php; if( !is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"), false, '1.3.2', true); wp_enqueue_script('jquery'); } Is it really worthwhile putting in a fallback call to a local copy of Jquery? If so, how? I originally had this in my header section; <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/libs/jquery-1.7.1.min.js"><\/script>')</script> It seems like a logical thing to have a fallback but just unsure how to implement this using the wp_enqueue and functions.php call.
January 16, 201214 yr Personally i wouldn't bother with a fallback. I understand that putting all your faith in the external copy may be a wrench but at the end of the day these things just have to done and gotten on with.
January 16, 201214 yr Author Personally i wouldn't bother with a fallback. I understand that putting all your faith in the external copy may be a wrench but at the end of the day these things just have to done and gotten on with. Now awaits google to go down lol
January 19, 201214 yr Hey man, I think you should always have a fallback to you local copy. Last week the Google CDN was down for a few minutes
January 19, 201214 yr Have no fear, I'm working on this one today. Will let you know when I've got something, shouldn't be long.
January 19, 201214 yr I remember seeing and article about this exact problem last Christmas. I'll dig through my bookmarks, see if I can find it. EDIT: Found it, but I'm interested in seeing what Chris comes up with so I'll post the link to it after he's finished. Edited January 19, 201214 yr by Spitfire
January 19, 201214 yr EDIT: Found it, but I'm interested in seeing what Chris comes up with so I'll post the link to it after he's finished. Ha! No pressure, then...
January 19, 201214 yr Ha! No pressure, then... Consider the pressure switch activated I was actually thinking about this question again the other night and i'm not happy with the original answer i gave (and i think i knew that). Fall back never hurts so why not do it? I shall amend my ways from now on and have fall back to a local copy
January 19, 201214 yr Personally, I'd stick to either just the CDN or just a local copy. Having a fallback in your functions.php basically means making a HTTP request to check that the CDN is still there on every time you refresh or change pages.
January 19, 201214 yr If you don't think it's reliable enough to use the googleapis then I'd just have a local copy. Can't see point of both?
January 19, 201214 yr Author Forgot about this! Am I right in thinking that my first example is the correct way of calling Jquery and that the second example (simply placing it in the header/footer) isn't really the way to go?
January 19, 201214 yr Personally, I'd stick to either just the CDN or just a local copy. Having a fallback in your functions.php basically means making a HTTP request to check that the CDN is still there on every time you refresh or change pages. So i guess this would negate any reason to use a CDN version in the first place?
January 19, 201214 yr Hmmm... I suppose it would. I didn't really think it that far through. Ah well, just for all you OCD people out there here's the article I mentioned previously: http://wp.tutsplus.com/tutorials/load-jquery-from-google-cdn-with-local-fallback-for-wordpress/
January 19, 201214 yr Hmmm... I suppose it would. I didn't really think it that far through. Come to think of it, that'd only be an issue if the CDN version was off-line and I'm sure that wouldn't happen much.
January 19, 201214 yr Here's my take: Loading JQuery from Google’s CDN with local fallback in WordPress. Sorry it took so long.
January 19, 201214 yr Author Here's my take: Loading JQuery from Google’s CDN with local fallback in WordPress. Sorry it took so long. Nice tut Chris, many thanks for posting
Create an account or sign in to comment