Our Blog

Google jQuery CDN - removing the render blocking resources in 1 simple step!

Google jQuery CDN - removing the render blocking resources in 1 simple step!

What is jQuery, why you should go with Google CDN and 1 easy step to remove it from a render blocking position!

Step: Removing Query Strings from Static Resources.

As all of us, bloggers, you want to increase the performance of your WordPress website. You have probably used tools like GTmetrix, Google Page Speed and Yslow which have suggested you to remove the render blocking JS (jQuery) and CSS from the head of your site.

Let’s now focus on the two annoying scripts in WordPress, which hinder page loading and are completely useless for visitors, especially if you have activated your own, newer version of jQuery.

In this case the question is not even in the version of the script, and that it appears in thesection. Let’s say that we have 2 extra requests (jquery.js and jquery-migrate.min.js) to the server which increase the website size by almost 200KB. All of us who have tried to speed up our blogs using PageSpeed ​​Insights were faced with this issue.

Let’s get to the scripts!

Your scripts may look like this:

http: //yourdomain.com/wp-includes/js/jquery/jquery.js

The trouble is thought, that they can not be simply removed. First of all, they are necessary for the correct operation of admin panel and secondly, when updating WordPress to a newer version – they reappear. Therefore, we need a way which would allow to keep these scripts in thefor visitors and at the same time keep admin panel operational. We can solve this by using the following script that you would need to add to your theme’s ‘functions.php’ file (between already installed scripts, or at the very end before the ‘>’ symbol). Remember to always make a backup copy just in case:

// Disabling jQuery
add_filter ( ‘wp_default_scripts’, ‘dequeue_jquery_migrate’);
function dequeue_jquery_migrate (& amp; $ scripts) {
if (! (is_admin_bar_showing ())) {
$ Scripts- & gt; remove ( ‘jquery’);
// $ Scripts- & gt; add ( ‘jquery’, false, array ( ‘jquery-core’), ‘1.11.1?); //Instead of 1.11.1 write your version of the jQuery file.
// Disabling jQuery

Note the version of your jQuery file. I am currently using WordPress 4.1.1, which, in the header, displays the version of jQuery as 1.11.1. Therefore, at the end of the last line of code you need to enter your current version of the script, which is displayed in the header of your site. To get the script version you can simply open the path to the file in a new tab and check the top right corner of the text page.

Making sure everything works.

Now check your admin panel. It is fully functional, and the scripts are not displayed for visitors. Final touch is to update the cache, mine is W3 Total Cache, and then check the loading speed:

All done, the Google scripts are no longer in the way, leaving only the CSS files. As you will see, the loading speed should have increased by around 10%, which is not that bad. And due to the fact that nowadays the search engine penalizes brutally slow and not fitted for mobile devices sites, eliminating these scripts is more relevant than ever.