Query Strings are little lines of code that follow primarily your CSS and JS resources they look like this ?ver=1.1 (the only important part is the “?”. They are meant to show the version of the file so that in the event of it being updated the visitors to a website are served the latest version. The fundamental issue with Query Strings is they aren’t always cacheable to some proxies, and that there are some cases when they simply aren’t needed.

So how do you remove Query Strings? It’s quite simple really and it can be done in a few lines. To do this simply add the following lines to a child theme functions.php file or a site specific plugin.

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

By adding those lines it should remove the Query strings that append your CSS and JS. However, if you are using a plugin such as W3TC you have an extra step.

Solution For W3TC Users

If you are a fan of W3TC like I am you might have accidentally enabled Query Strings from the plugin. To remove them you need to go into your Browser Cache settings and uncheck “Prevent caching of objects after settings change” and save your settings.

Remove Query Strings W3TC

Solution For The Non-Technical 

If you are not a developer and are worried about adding code to your theme or creating your own plugin then the third and final option is to install a plugin. Now before, you say won’t that slow my site down the answer is no.

Adding a plugin to your site doesn’t make it slow but you should always try to do as much as you can with as few as possible. Adding one plugin that does the code above VS adding it to your functions.php file or in another plugin won’t make any difference in terms of performance.

Add the following plugin to your website and it contains the code I added above.

Remove Query Strings Plugin


Please enter your comment!
Please enter your name here