5+ Easy Ways to Remove Query Strings from Static Resources

guide to help you remove query strings from static resources in wordpress website

Through this guide today, I would like to share with your guys 5 different ways to remove the query string from static resources such as stylesheets, Javascript, or even images in WordPress sites.

I don’t need to explain to you the importance of website speed. I mean, we all know its significance regarding search engine optimization and user experience. Dozens of experiments and publications have been released, highlighting the impact of the site’s page load delays on the overall user experience and revenue.

Recently, Google has also released a new algorithmic update that focuses mainly on the speed of a site on mobile devices. So, if your blog or online magazine is not properly optimized for small devices like tablets or smartphones, you will very likely experience a decline in organic search traffic from mobile devices.

How to Remove Query Strings from Static Resources in WordPress

If you have created your site on WordPress, then it’s indispensable to remove query strings from JS and CSS files; otherwise, your website will have serious performance issues.

With WP, you get the freedom to install and then activate or deactivate templates or extensions. Each of such templates and extensions probably loads their own static files, and most of the time, these files will have parameters attached to them.

Now, this won’t be an issue for you if you don’t have any intentions to grow your blog or website. But if you really want your site to rank better on search result pages, then you must get rid of query strings; otherwise, there will be issues with gzip compression, cache, and google page speed score.

There are dozens of methods and extensions available on the internet to help you fix this issue. In this guide, I will be sharing with your guys five simple and easy to follow methods. The first method will require you to edit your theme while the rest four methods will be related to the usage of plugins.

You must understand that removing them is really important. It will help to leverage browser caching and will also enable gzip compression on static files.

Remember that you don’t need to follow all the methods. You just need to choose one method, and then you have to implement the steps listed in this guide on your website. Once you have followed and implemented all the instructions, you can perform a website load test using tools like webpagetest, Pingdom, or GT Metrix, etc.

If you have followed all the steps properly, you will definitely notice improved page speed and yslow scores.

1. 100% working code snippet – my favorite

This method involves editing your theme’s functions.php file, but it also means that you don’t have to use any plugin.

Before you proceed with this method, I will suggest you create a full backup of your site. If not full site, then at least create a backup of your theme just in case anything goes wrong.

Now visit your website’s administration panel. Put your cursor on appearance and then click on the editor. You need to navigate in the following order ( wp-admin -> appearance -> editor ).

Once you are on the themes editor page, look for the “Theme Functions” file and then open it.

Now copy the code listed below.

/* To handle question mark */
function dg_rm_qs_ques( $src ){
$rqs = explode( '?ver', $src );
return $rqs[0];
if ( !is_admin() ) {
add_filter( 'script_loader_src', 'dg_rm_qs_ques', 15, 1 );
add_filter( 'style_loader_src', 'dg_rm_qs_ques', 15, 1 );

/* To handle ampersand */
function dg_rm_qs_amper( $src ){
$rqs = explode( '&ver', $src );
return $rqs[0];
if ( !is_admin() ) {
add_filter( 'script_loader_src', 'dg_rm_qs_amper', 15, 1 );
add_filter( 'style_loader_src', 'dg_rm_qs_amper', 15, 1 );

Once you have copied the code snippet, make sure to paste it at the bottom of your theme’s functions.php file. Now, to save this file, you will need to click on the blue “save changes” button.

If you are using any cache plugin, then make sure to flush all your site’s cache.

Visit your site to see the changes.

2. WordPress speed optimization plugin

speed optimization plugin

With the help of this extension, you cannot only remove query string from static resources, but you will be able to control more than 53 website speed optimization related settings.

This installs this extension and then under the “Must Optimize” section, select all the appropriate options, and then click on the Save button.

Now reload your website and enjoy the improved website speed and performance.

3. W3 total cache

One of the world’s most popular cache extension for WordPress websites comes with an inbuilt option to remove query strings from static files.

If you already have this plugin installed on your site, then all you need to do is to follow a few simple steps listed below.

  • Go to your site’s administration panel.
  • Navigate to the W3 settings page and then go to the “Browser Cache” section.
  • Simply select the options shown in the image attached below.

Now make sure to save your settings.

4. Query Strings Remover

It’s a free extension available for download on the official plugin repository by LittleBizzy. It has more than 10,000 active installations and has received a 4.7/5 rating based on ‎38 reviews. Currently this addon supports the removal of ?=, ?v=, ?ver=, ?version= types of parameters. If you have any questions to ask before installing it, then you can visit the official support forum and ask for answers.

Note: This extension doesn’t provide you with any settings page. All you have to do is to install and it and flush your site’s cache.

5. Reduce HTTP Requests, Disable Emojis & Embeds

make sure to choose this option

WP disable one of the best freely available WordPress speed optimization plugin. Developed and maintained by Jody Nesbitt, this addon has more than 30,000 active installations. Furthermore, it is actively maintained and has a 4.5/5 rating based on 35 reviews.

Once you have installed and activated this addon, you will be automatically redirected to its settings page. On the settings page, look for the “Remove Querystrings” option and then click on the toggle button.

What is query string, and why it’s so important in web development?

As the name sounds is a small string affixed to the static files. You will usually find attached to JS, CSS, or dynamic images. Most of the time, they start with a question mark along with equal to (=) sign and some digits. Sometimes you may also find query strings starting with an ampersand (&).

Below you can see some example:


Now, you might have a question, what these random strings so important in the field of web development?

A web developer normally adds a unique identifier as a parameter to the static file’s URL.


Well, because web browsers usually ignore caching any files with a query string. So, it’s helpful for the developers to publish the latest updates to the website or the applications almost instantly.

These updates can be related to security or can be just a minor bug fix. Since developers don’t have to worry about the cache-related issues, the latest security patches and UX improvements can be delivered to the client’s browsers without any compromises. This ensures safety and better usability across all devices and across all web browsers.

Note: You have to consider the fact that developers and businesses don’t care about Google Page Speed scores, especially when it comes to dynamic web applications (for example, Facebook, Twitter, etc.).

Now let’s get back to the main topic.


Written by .