How to Make jQuery Loading Faster in WordPress

By default, WordPress load its own copy of jQuery file located in wp-includes/js/jquery/jquery.js, calling wp_enqueue_script(‘jquery’). But loading the jQuery from Google Hosted Libraries will make the web faster, providing numerous potential performance benefits:

  • Increases the chance that a user already has these files cached
  • Takes load off your server
  • Google’s servers are set up to negotiate HTTP compression with the requesting browser

Here’s an easy way to do it. Paste the code below into your functions.php file:

function google_jquery() {
   if (!is_admin()) {
      wp_register_script('jquery', '', false, '1.10.2');
add_action('init', 'google_jquery');

Once you saved the file, WordPress will load jQuery from Google CDN, making the web faster.

Leave a Reply

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