HomeGuides & Tutorials

Remove Query Strings from Static Resources in WordPress.

Remove Query Strings from Static Resources in WordPress.
Remove Query Strings from Static Resources in WordPress.
4.1 (82.5%) 8 votes




When testing our Website in tools such as GTmetrix , we often come across warning such as Remove Query Strings from Static Resources.
The recommendation provided to Remove the Query Strings should not be overlooked because it has priority in determining the speed of the Website.

How will this article help you ?
This article focuses on three modules of Query Strings:
1.A Basic Guide on Query Strings that covers the points such as what are Query Strings and how does it affect the performance of the website.
2.Removing Query Strings using code.
3.Remove Query Strings using Plugins.

1. The Basic Guide

What are Query Strings

Resources such as CSS and JS files in your website with a version number appended at the end are Query Strings or simply we can call Query Strings as “URL with Query parameters such as “?”.

How does Query Strings affect the performance of the website

Many Hosting Providers and CDN services has the problem in Caching of these resources which affects the loading time of the website and ultimately lowering its performance.

Now that you have read through the basics, it is clear as to why “Removing Query Strings from Static Resources” is Important.

2. Removing Query Strings using code

In order to accomplish this task, open the functions.php file of your theme by navigating through Appearance -> Editor -> functions.php and add the snippet of code provided below.
The file can also be located if you have the access to the FTP or CPanel


function _remove_script_version( $src ){
    $parts = explode( '?ver', $src );
        return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Source

Remember : It is always recommended that you take a backup of the file before editing.

3. Removing Query Strings using Plugins

There are Plugins that can simplify the task of removing the Query Strings.

Remove Query Strings from Static Resources


Now you can boost your speed score in GTmetrix, Google Page Speed using this simple plugin which just needs to be activated after Installing it. The plugin removes all of the Query Strings from CSS and JS files that are located with the HEAD element.

Download of the Plugin as of writing this post : 90,000+

Download

Query Strings Remover

With no Configuration required this plugin does the same task of removing Query Strings from Static Resources such as CSS and JS files.
It is recommended to delete the cache after activating the Plugin.

Download of the Plugin as of writing this post : 10,000+

Download

WP Performance Score Booster

This Plugin provides more than “Removing Query Strings from Static Resources”. It helps in Improving your website speed by enabling GZIP Compression and Browser Caching. Using this Plugin you can improve your website score in page speed tools such as Pingdom, GTmetrix and Google Page Speed

Download of the Plugin as of writing this post : 40,000+

Download

Conclusion

I hope this guide will help you in removing the Query Strings from Static Resources in WordPress thereby Improving your website speed. You can also refer The INs and OUTs of WordPress Speed Optimiztion that will guide you through the various methods that you can Implement in your Site to make it faster.

Comments (0)

Leave a Reply

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