How to remove query strings from static resources with a WordPress plugin.

no cost

Save the Internet from WordPress speed abuse.

Updated: December 2017

4 minute read

WordPress by default adds query strings – “?” or “&” – to the static CSS and Javascript resources files used in your site. Gtmetrix, Pingdom, or Google’s PageSpeed Insights online speed tests urge removing these.

But, WebPagetest.org doesn’t. Why? Maybe WPT.org feels like we do: Better scores aren’t equal to speed changes.

Removing Query Strings makes a significant improvement in page speed. That’s the claim anyway. We’ve never seen “significant” speed improvement. That word “significant” gets used a lot with speed test braggadocio. The word should shoot up a suspicious red flag. The removal-suggestion always changes your speed test score. Big deal. Scores aren’t the same as load time gains.

A lot of speed technical stuff is hot air. Nerds puffing their chests out to prove who’s the biggest and best nerd. Removing query strings is one of those technical things that doesn’t make much difference in the world. But speed tests insist it’s important for a good score.

Usually “query strings removal” improves load times by milliseconds – and not seconds.

IMO it is recommended to ignore 50% of the Google PageSpeed recommendations, this is one of them:

‘Resources with a “?” in the URL are not cached by some proxy caching servers. Remove the query string and encode the parameters into the URL for the following resources…’

… the chances of any page of any small or medium site being cached – and reused from the cache is minimal. … removing static resources is not worth the zero speed improvement your site will gain. Author – Mark Kaplun

So, what the heck are Query Strings?

Query strings are the URLs containing special characters such as “&” and “?”. Scripts and stylesheets often contain a modified URL to identify versions.

Query strings can help track users like HTTP cookies. Query strings are often used in association with web beacons. Google Analytics uses web beacons (a 1-pixel, square, transparent, GIF image). A web beacon is an object embedded in a web page or email. It allows checking that a user accessed the content.

What’s cache busting?

Speed improvements do not improve SEO. They improve UX. Google doesn’t use PageSpeed test scores in it’s ranking algorithm. They use TTFB (time to first byte). TTFB is host-server access-time – a speed overhead measured in milliseconds.

Browsers store a cached static file until an expiration date. The file version in your visitors’ browser may prevent seeing new changes.

Cache busting solves the problem with a unique file version identifier. This tells the browser a new file version is available. Then the browser doesn’t retrieve the old file from cache. Instead, it makes a request to the original server for the new file.

The query string is a method for plugins and themes to pass version details about new updates. This trick is a plugin author’s workaround or “cheat.” It’s not best-practice. And may have a theoretical impact on website loading speed. Removing the query string from the file name “fixes” this without harm. But in reality, it only improves your speed score – and not the milliseconds of extra load time we yearn for.

You can remove query strings from files – without touching a single line of code.

Below, we give a list of free, lightweight plugins that do the job for you. These plugins need no configuration. They’re all plug and play. Install and you’re good to go. Make sure to clear your cache after installing to see changes. You can download the plugins from the WordPress repository. Or by searching within your WordPress dashboard under “Add New” plugins.

These plugins search all static files loaded from plugins or themes for “?” or “&”. Then removes them. This won’t damage website functionality. It helps your website get better page speed scores. It may even help make your site faster. But better speed is rare.

Removing Query Strings From URLs With Free Plugins

Remove Query Strings From Static Resources
90,000+ active installs, compressed download 2.5k.

Query Strings Remover
9,000+ active installs, compressed download 1.6k.

Remove Query Strings
800+ active installs. compressed download 5.2k.
Remove Query Strings From Static Resources Like CSS & JS Files
3,000+ active installs, compressed download: 2k.

Static Resource Cleanup by Removing Query Strings
100+ active installs, compressed download: 2.7k.

Zendy Speed: Query Strings
2,000+ active installs, compressed download: 1.8k.

These plugins are super lightweight and benign. You may see millisecond improvements. There’s no reason not to install one for speed.

The bottomline is: removing query strings does no harm – but the only benefit most likely is an improved test score – not speed. Of course, the question is, “Why do speed tests insist it be done?” It’s ivory tower idealism.

 

Get our book “SPEED EVIL” at Amazon Kindle.

Godspeed—

Steve Teare
performance engineer

Mobile WordPress Speed – without coding!

What others think of us:


"I’m absolutely delighted and I wouldn’t have got anywhere near the 1-second load time without your guidance, so I’m eternally grateful." UltraWords.com  United Kingdom

by - Jonathan Westwood