Why You Shouldn’t Remove Query Strings from Static Resources?Share Tweet Share Pin it
We have been tough by a number of web experts that we should remove the query strings from the static resources in order to faster website loading time.
But that was told for a reason and that reason is no longer valid now because we have moved from static websites to dynamic ones.
Query strings are there for many reasons, and removing them may harm some functionalities. Let’s see what are the plus sides of using and not removing query strings:
It Tells Browser to Cache Refreshed Static Files
How? Actually query strings are tied with a number like a theme’s version, plugin’s version, or anything similar script resources. Whenever such thing updates, that version also gets updated because the developer needs to tell the version number for the update.
If you do not use those query strings or anyhow removes it, your browser won’t see any difference between both the files. The browser just checks for the file name from the cache.
|Version||w/ Query Strings||w/o Query Strings|
|Outcome||Code always changes with the query strings.||Code never changes, unless manual refresh is made.|
Here any changes made in the script won’t be visible unless you hard refresh your browser, or just remove the cache from the browser. From the admin side, you’ll do it, but not your visitors.
That’s why for dynamic websites query strings are useful and shouldn’t be removed.
However, if you are using dynamic CMS to make a static site then you can remove it. Because no code is going to change there often. So it should be safe to remove.
Query Strings Do Not Use Any Server Resource
Yes, that’s right! Query strings do not any additional server resources to the process they just get loaded with all the static resources. If you have tried to enqueue scripts you’ll better know how it works. In WordPress, it uses either theme’s or plugin’s version number as a query string.
Every Browser Supports Query String
I never heard of any browser that doesn’t support query string. It was supported since the dynamic websites used to exists. Today almost every website is dynamic.
Website Benchmarking Tools No Longer Recommends to Remove the Query Strings from Static Resources
If you frequently test your website for speed and performance measures, the good news is, those tools do not consider or suggest to remove the query strings from the static resources. You can try out GTmetrix, Google’s PageSpeed, or any other similar benchmarking tool.
So, again, my main question remains same: Why are you trying to remove query strings?