Jquery from CDN is getting 404 errors

I am getting 404 errors on the CDN version of jQuery. It is showing up in my HEAD like so:

<script type='text/javascript' src='/ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>

The browser sees that as relative path on my site and I get a 404 error for ‘http://mysite.com/ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js’ which, of course, doesn’t exist. Has anybody else seen this before? How can I fix it?

Check lib/scripts.php. The source should have two forward slashes, not one (so that it’s protocol agnostic).

If it’s not that then it’s likely to be one of the plugins you have installed.

If you’re not familiar with this structure (or maybe it’s just a typo) check out this article by Paul Irish.

http://www.paulirish.com/2010/the-protocol-relative-url/

He’s done a really great job of breaking this down. Especially helpful if you’re planning on having any SSL enabled features on the site.

This is the function, as used, in the lib/scripts.php file.

function roots_scripts() {
  wp_enqueue_style('roots_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '9dbd7d094ab56a14e3b2a984b20ea357');

  // jQuery is loaded using the same method from HTML5 Boilerplate:
  // Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline
  // It's kept in the header instead of footer to avoid conflicts with plugins.
  if (!is_admin() && current_theme_supports('jquery-cdn')) {
    wp_deregister_script('jquery');
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, null, false);
    add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2);
  }

  if (is_single() && comments_open() && get_option('thread_comments')) {
    wp_enqueue_script('comment-reply');
  }

  wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.7.0.min.js', false, null, false);
  wp_register_script('roots_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', false, 'be373268f9b8ecda7c3a45154676e637', true);
  wp_enqueue_script('modernizr');
  wp_enqueue_script('jquery');
  wp_enqueue_script('roots_scripts');
}
add_action('wp_enqueue_scripts', 'roots_scripts', 100);

I’ll try deactivating plugins.

Well, this is embarrassing. The error was indeed caused by a plugin. All is well, now.

I’m curious, which plugin was causing that to happen?

It should have been obvious to me which plugin was causing the problem, which makes it all the more embarrassing for me to post it here. It was the ‘Root Relative URLs’ plugin. Yeah. Funny thing is I don’t remember ever installing it.