Call Google’s jQuery Library in Your Template

Why use your own bandwidth when you can use Google’s own! This snippet ensures your WordPress website correctly calls the Google jQuery library direct from Google for speed, security and reliability:

// Use the google CDN version of jQuery
function wpfme_jquery_enqueue() {
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://", false, null);
if (!is_admin()) add_action("wp_enqueue_scripts", "wpfme_jquery_enqueue", 11);

NB: Just make sure you use the above with…


…in your header file, or wherever your wp_head scripts get called from.

Useful post? Share it

Leave a Reply

Your email address will not be published. Required fields are marked *