When you will test your website’s performance by different tools or website such as Google, GTMetrix, Pingdom, KeyCDN etc., you must have seen an issue named “Remove query strings from static resources“.
To speed up your WordPress website’s performance, you should to remove query strings from static resources.
Recently I changed my website theme to WP Ayaat, a blazing fast WordPress blogging theme for professional. As a Professional WordPress developer, I should check my website speed after changing the theme and what I did using GTMetrix and Pingdom.
As usual, I have found Remove Query Strings From Static Resources.
So, What are Query Strings? The query string is the part a URL that contains content values or carry the version details. For WordPress website, it generally carries version numbers of static resources like images, javascript (.js), stylesheets (.css) etc. and sometimes it carries WordPress version number also.
Generally, query strings URL’s have “?” in their URL’s. In WordPress, it is generally implemented by developers to instantly render new updates. Developers use query string as it is not cached by most of the browsers and CDN services.
And why Query Strings Should be Removed? Though query strings might be helpful for web developers and designers but query strings have a great impact on website’s loading speed. Almost all the search engines, browsers, web hosts nowadays do not index or cache the resources or URL’s that have “?” in their URL’s.
Remove Query Strings by Code
If you want to remove query strings with code, simply copy this in themes functions.php.
After this, most of the query strings will be removed from static resources. But sometimes developers use WordPress version number as query strings. WordPress version strings may not removed by using the function. To remove WordPress version strings, add the following function.
Use both functions to completely remove query strings. And if all goes well, you should no longer see a warning about query strings in website performance test tools such as Pingdom.
Remove Query Strings by Plugin
You can also remove query strings by using plugins. There are many plugins can do that action. I recommend to use Remove Query Strings From Static Resources plugin. After activating the plugin, it should work.
And if you are using W3 Total Cache plugin plugin, you need to enable an option to sort this issue. This option can be found by navigating to the W3 plugin Performance tab > Browser Cache. Within the General section of this page there is an option called “Prevent caching of objects after settings change”.
Removing query strings from static resources is important since if they remain, they can cause caching issues. Certain proxy caching servers and even some CDNs cannot cache static assets with query strings, resulting in a large missed opportunity for increased speeds.
I am sure, now you know how to remove query strings from your WordPress site. If my method not works, please let me know using comment box bellow.