How to remove query strings from static resources

The page load time is essential for any website. It enhances user experience as well as search engine rankings of your site. However, various aspects can effect website load time. One such aspect is query strings from static resources.

Do you want your WordPress website to perform well on the platforms such as Google Page Speed Insights, YSlow, Pingdom, or so on? Perhaps, by removing query string from static resources, you can tackle this problem. In this article, I will be presenting you the ways through which you can remove query strings.

But before we head to removing them, it is important to know more about query strings.

What exactly are query strings resources in a WordPress website?

In a WordPress site, query strings resources are those URLs that have “&” or “?” character in them. Even after optimizing Public Cache-Control Headers, Proxy servers often fail to cache CSS and JavaScript resources having Query strings.

Additionally, some of the CDNs also fail to cache resources with Query Strings. You can test or check the source code of your website through tools like Yslow and GTmatrfix.

Remove Query Strings from Static Resources
Remove Query Strings from Static Resources

Removing Query strings from static resources

There are two solutions for removing Query strings. In the theme’s file “function.php”, you can add a PHP code for removing it. While you can also add a plugin to your WordPress website to get it removed. It is also an easy method to get this task done. Let’s look at both of the methods in details.

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

By Using plugins

You can easily remove query strings from static resource quickly by adding a WordPress plugin to your WordPress website.

There are various plugins available in the market that can get this task done such as Remove Query Strings from Static Resources, Query Strings Remover, Speed Booster Pack, etc.

This solution is ideal especially if you aren’t familiar with PHP coding. Theme updates won’t affect this feature, but even though theme updates remove it, then you can easily get it back through the plugin.


Its very important to Removing Query Strings from Static Resources like CSS & JavaScript to increase your website page loading speed. By applying above solution you will notice improvement in Page Speed Grades on GTmatrix and Pingdom.

Also ReadHow to remove tagline from genesis child theme


What's Your Reaction?

Love Love
Geeky Geeky
Fail Fail
Cute Cute
Choose A Format
Formatted Text with Embeds and Visuals