Remove query strings from CSS and Javascript

Remove query strings from CSS and Javascript

Theme and plugin developers often add a version number to the CSS and Javascript files. This way they force the browser to always load the most recent versions. It also causes these files not to be cached, because of the query string added to the file name. So every file must be reloaded every time it is needed. This affects the performance of your website.

You can remove the query strings by using a plugin. A caching plugin will also remove the query strings. If you don’t want to use a plugin, you can use the code below.

Put the code into the functions.php of your theme. Test the effect with a tool like GTmetrix. Run the test before and after you put the code into functions.php and see the difference under “Remove query strings from static resources”.

Always backup the functions.php before you start changing it!

Ronald Heijnes

Since 2008 I have been busy with the functionality, management, maintenance and performance of self hosted WordPress. I like to share this knowledge!

Leave a Reply

3 Comments on "Remove query strings from CSS and Javascript"

Notify of
avatar
Sort by:   newest | oldest | most voted
wpDiscuz
Close Menu