Remove Query Strings From Static Resources

< 1 min read

If you’ve done a page speed test on a website like GT Metrix, you might have come across a suggestion to remove query strings from static resources. If you right click > view source on your website, you may well see a number of URLs for your css or javascript files similar to http://www.mydomainname.com/wp-includes/js/jquery/jquery.js?ver=1.10.2.

The problem with these query strings is that many proxies do not cache resources with a “?” in their URL so it’s a good idea to remove these query strings from references to static resources. Removing them is actually pretty straight forward:

1) Locate your themes functions.php file. You can normally find this file if you navigate to “Appearance” > “Editor” and look in the list of list on the right hand side.

2) Copy and paste this code into your functions.php within the php tags.

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

3) Save your functions.php file, refresh your website and view the source again. This time you should see that the query strings have been removed.

Tristan Whittaker

Tristan Whittaker is a website consultant and digital strategist with over 20 years’ experience helping businesses grow online. As the founder of Infinity3, he specialises in creating high-performing websites that not only look the part but actually deliver results. Tristan combines deep technical know-how with a clear, no-jargon approach — offering practical advice and expert guidance to help businesses build a stronger, smarter online presence with confidence.

Leave a Comment





Need Help Taking the Next Step?

Let’s Put These Ideas to Work for Your Business

We don’t just talk about strategy — we implement it. Whether you’re looking to improve your SEO, launch a new website, or explore AI-powered tools, we’re here to help.

Let’s chat about how Infinity3 can support your next move.