Why you shouldn’t remove query strings from static resources?

Published in

on

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
Query Strings

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.

Versionw/ Query Stringsw/o Query Strings
Version: 1.0style.css?ver=1.0style.css
Version: 1.1style.css?ver=1.1style.css
Version: 1.2style.css?ver=1.2style.css
OutcomeCode 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?

Leave a Reply

Your email address will not be published. Required fields are marked *