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, is a free, lightweight plugins that’ll do the job for you.
This plugins need no configuration. It’s 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 plugin from the WordPress repository. Or by searching within your WordPress dashboard under “Add New” plugins.
This plugin searches 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.
Our choice:
★ ★ ★ ★ ★
WP Remove Query Strings From Static Resources
Load Time: 10 milliseconds
These plugins are super lightweight and usually 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.
We consider it a vanity metric.
Godspeed-
Steve Teare
performance engineer
September 2023
PagePipe Site Tuning Services for Speed
Instead of band-aid approaches, we drill down to the root cause of your slow site. This is origin optimization. Also known as site tuning. To do this, we analyze site components:
- Hosting
- Theme
- Plugins
- Scripts and third-party services.
- Images and media library.
- We minimize globally loading plugin effects.
Find out more details about Site Tuning – Get Speed!