Skip to content

Instantly share code, notes, and snippets.

@BFTrick
Created October 16, 2012 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BFTrick/3901484 to your computer and use it in GitHub Desktop.
Save BFTrick/3901484 to your computer and use it in GitHub Desktop.
Load jQuery From CDN With Local Fallback
//include jquery - use an empty file path which is basically a promise to WP that you'll hardcode it into your theme
wp_deregister_script('jquery');
wp_register_script('jquery', '', FALSE, '1.8.0', true);
wp_enqueue_script('jquery');
@BFTrick
Copy link
Author

BFTrick commented Oct 16, 2012

Inspired from WPShock.

I'm still not successfully passing the $url variable into the load_external_jQuery() method.

@BFTrick
Copy link
Author

BFTrick commented Oct 16, 2012

Switched to using the Ben Everard method instead. You still have to include the HTML5 Boilerplate jquery loading method in your theme.

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="<?= get_stylesheet_directory_uri(); ?>/assets/js/jquery-1.8.0.min.js"><\/script>')</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment