If you are looking for tips on how to remove query strings from static resources – you came to the right place. In this article, we will discuss why and how you should remove them from your static resources.

What are Query Strings?

A Query String is an input in the address bar that asks for specific information on the website. It starts with ? and is followed by &s. Query strings are there by default, with the main function of handling versioning of files called static resources.

Static resources are CSS, JavaScripts, multimedia, and downloadable files like PDFs, or ZIPs.

Query Strings can cause some catching problems for your website.

Using WordPress plugin

1. Remove Query Strings From Static Resources

Remove Query Strings From Static Resources WordPress Plugin

If you are a WordPress user, the easiest way to remove query strings is by utilizing a plugin. You don’t even have to look for one yourself, as we have a collection of recommended plugins:

Remove Query Strings From Static Resources is a great option. This is a 4-star rating plugin with 100.000 active installations. It is completely free too!

This plugin cleans the Query Strings from resources located inside the HTML <head> element.

So, if you ever get a warning about improving your speed score by removing query strings, give this plugin a try.

To access the plugin, go to your WordPress Dashboard, and search for Remove Query Strings From Static Resources in the plugin menu. Then, click install, activate, and let the plugin do the job for you. Easy, isn’t it?

2. WP Rocket

WP Rocket WordPress Plugin

Next, we have WP Rocket plugin. This caching plugin has a great reputation. It optimizes many websites and offers quick setup. The features of this plugin include cache preloading, database optimization and, of course, removing query string from static resources.

After installing it, just go to Basic Settings, and make sure to enable the Remove query strings from static resources option.

3. Speed Booster Pack

Speed Booster Pack WordPress Plugin

This lightweight plugin is a great option with more than 40.000 active installations. Regularly updated, its competence in improving web loading is undoubted.

The main features of this plugin are

  • Move scripts to the footer
  • Remove query strings from static resources
  • Remove junk header tags
  • Remove the WordPress Version

From the plugin Settings page, check the Remove query strings option located in the General Options.

4. W3 Total Cache

W3 Total Cache WordPress Plugin

When configured well, this highly-trusted plugin will improve user experience by boosting website performance and reducing download times. W3 Total Cache has good compatibility with shared hosting, virtual private servers, and dedicated servers.

After installing this plugin, you will find the Browser Cache option in the Performance section. Uncheck the option Prevent caching of objects after settings change to avoid query strings creation.

5. Comet Cache

Comet Cache WordPress Plugin

You just need few clicks to manage cache with this plugin. This plugin lets you set the expiration time for the cached resource and promises a more optimized performance.

You can get abundant features for free like caching for 404 requests, option for caching or ignoring URLs that contain query strings, and HTTP referrer exclusion patterns.

Get the PRO version if you need features like Auto-Clear a List of Custom URLs, Automatic Updater, Server Load Monitoring, and even HTML Compression.

  • Installing this plugin, go through these steps:
  • Upload /comet-cache folder to /wp-content/plugins/ directory.
  • Activate the plugin.
  • Go to Comet Cache panel
  • Enable it.

Using Code

Other than simply installing plugins, WordPress users can use code too. When doing so, make sure that the code is written correctly.

All you need is to modify the functions.php file to remove the query string. First, log in to your Dashboard, go to Appearance -> Editor. Then, add the following code.

unction _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 );

Conclusion

You can improve your web performance by maintaining page loading speed. Removing query string from static resources is a right thing if problems occur.

After you remove the query string from static resources, you can test your web performance with tools like Gtmetrix or Pingdom to know your website’s score.

  • php
  • my sql
  • intel
  • cloudlinux
  • nginx
  • cloudflare
  • wordpress