Skip to Content

How to Remove Query Strings from Static Resources

Sharing is caring!

Page load time is an extremely important factor as it helps in ranking on Google search. So to get a higher ranking, your website speed should be a decent one.

If you have checked the earlier posts then you will know that here we are discussing the analyzing results of GTMetrix.

We have checked How to defer parsing of java and now moving on to removing query strings from static resources.


Before we jump directly, let us see what are query strings at first.



On the World Wide Web, a query string is the part of a uniform resource locator (URL) containing data that does not fit conveniently into a hierarchical path structure~ Wikipedia


It means that the query strings are the special characters as ‘?’ which are sometimes used to denote the version of the string used or to pass the content value, which helps in the cache-busting technique.


A query string looks like this:

We need to remove the query strings from static resources as it hinders the caching and as a result, delayed load time occurs.

Caching of Static Resources like CSS and JavaScript plays a vital role in decreasing page load time.



When you will analyze your site URL in GTMetrix, you will see ‘remove query strings from static resources is one of the factors which affects the site speed, though its priority is low.

This is what I got after editing my PHP files.


Remove Query Strings From Static Resources




This is my recommended method as I always try to use fewer plugins for my site.

Warning! Copy the original files separately before editing function.php or htaccess. As minor mistakes can mess up your site.

1. WordPress Dashboard> Appearance> Editor

Remove Query Strings From Static Resources


2. On the right side, you will find your PHP files

Remove Query Strings From Static Resources


3. Click on Function.php> Scroll down to the bottom> and include the following codes:

/*** Remove Query String from Static Resources ***/
function remove_cssjs_ver( $src ) {
if( strpos( $src, ‘?ver=’ ) )
$src = remove_query_arg( ‘ver’, $src );
return $src;
add_filter( ‘style_loader_src’, ‘remove_cssjs_ver’, 10, 2 );
add_filter( ‘script_loader_src’, ‘remove_cssjs_ver’, 10, 2 );


Remove Query Strings From Static Resources

This plugin will remove query strings from static resources like CSS & JS files inside the HTML <head> element to improve your speed scores in services like Pingdom, GTmetrix, PageSpeed and YSlow.


Remember this plugin only remove the query strings located in the <head> section and not the <body>.

Download the plugin from the link already given

Or Install from WordPress Plugin> Activate

No need to configure anything. This plugin will solve the removal of query strings in just 1 click.




If you are worried about your website speed then you must Leverage your browser cache and use a proper free CDN.

You can also check the 11 best image optimizers for WordPress which will reduce the byte size and hence faster loading.

Next, we will check how to reduce DNS lookups.

Sharing is caring!

Tony Hisir

Monday 14th of September 2020

Hi Moumita, I have a handmade jewelry wordpress website and trying to increase the speed. I will appreciate your advice. Thank you and best regards, Tony