Blog · WebJi® India

Remove Query Strings in WordPress

Quick answer: Removing query strings in WordPress means stripping the ?ver= value from CSS and JS URLs, usually with a filter on script_loader_src and style_loader_src or a plugin toggle. It only helps where a proxy or CDN refuses to cache URLs with a query string; modern caches ignore them.
✓ In business since 2005✓ INR + GST billing✓ 24/7 Email Support — avg reply < 60 min
Modern data center corridor in India with rows of server racks under cool blue-white lighting — remove query strings wordpress

What a query string on a CSS file actually is

Removing query strings in WordPress means stripping the ?ver= value that WordPress appends to enqueued CSS and JavaScript URLs, so a file loads as style.css instead of style.css?ver=6.8.2. That value is a cache buster: it changes when the theme or plugin version changes, which forces browsers to fetch the new file.

  • Where it comes from — wp_enqueue_style() and wp_enqueue_script() accept a version argument and add it as a query string.
  • What it protects — after an update, visitors get the new CSS instead of a stale copy from their browser cache.
  • What it is not — a tracking parameter. Removing it changes nothing about the file itself.

Why the speed tools flag it, and when that advice is stale

The warning comes from an older era of proxies and CDNs that skipped their cache for any URL containing a question mark. On those systems, a versioned file was fetched from the origin on every request, which was slow.

Most CDNs now cache query-string URLs by default, and browsers have always cached them. On a current stack, removing ?ver= usually moves the score by a point or two and changes load time by nothing measurable. Treat the warning as a checklist item, not a performance fix.

It is still worth doing when your host, CDN or a corporate proxy is configured to ignore query strings. Check that before you spend time on it.

Remove them with a plugin toggle

The click path is short, and it is the safer option for anyone who does not want to edit theme files.

  1. Install Perfmatters, or the free WP Remove Query Strings From Static Resources plugin from the WordPress plugin directory.
  2. For Perfmatters, open Settings, then Perfmatters, then the Options tab and the General section.
  3. Switch on Remove Query Strings and save the settings.
  4. Clear the page cache and any CDN cache, then reload the site in a private window.

For the free plugin there is nothing to configure: activating it is the whole step. If you already run a caching plugin such as LiteSpeed Cache, check its settings first, because it may offer the same toggle and two tools doing the same job can conflict.

Remove them with a functions.php filter

The code route touches two hooks and one core function. Put it in a child theme's functions.php, or in the Code Snippets plugin so a theme update cannot erase it.

  1. Open Appearance, Theme File Editor, and confirm you are editing the child theme, not the parent. If no child theme exists, use Code Snippets instead.
  2. Add this function at the end of functions.php, before any closing PHP tag is not needed because the file should not have one.

function webji_strip_ver( $src ) { if ( strpos( $src, 'ver=' ) ) { $src = remove_query_arg( 'ver', $src ); } return $src; } then add_filter( 'script_loader_src', 'webji_strip_ver', 15 ); and add_filter( 'style_loader_src', 'webji_strip_ver', 15 );

Save, then reload any page. If the site returns a white screen, you edited the parent theme or missed a semicolon: restore the file from a backup and use the plugin method instead.

Verify the change with one command

Purge the cache first, or you will be reading the old HTML. Then count the remaining versioned URLs on the homepage.

  1. Run curl -s https://yourdomain.in/ | grep -o '?ver=[^"]*' | wc -l. Before the change the number is above zero; after it should be zero, or close to it.
  2. If the count stays high, view the page source and find which files still carry a version. Assets added by a plugin with a hardcoded URL are not touched by either hook.
  3. Open the browser console, reload, and confirm no CSS or JS file returns a 404.
  4. Run GTmetrix or PageSpeed once more. The Remove query strings audit should be gone, and you can judge whether anything else moved.

The failure: the site loses its styling

The page loads with no CSS after the change, usually because the browser is holding an old cached copy and the version that used to force a refresh is gone. Press Ctrl and F5, or open the site in a private window, and the styles normally return.

If the layout stays broken in a private window, a file genuinely failed to load. Open the console, read the 404 path, and check whether a plugin renamed that asset. Revert the toggle or comment out the filter, confirm the site is healthy, and fix the asset path before trying again.

The lasting fix for cache busting is to version files by modification time rather than by removing the version. A behind-the-scenes change that edits CSS without changing the plugin version will otherwise reach returning visitors late.

When to leave the query strings alone

Leave them when your CDN already caches query-string URLs, because the warning is then cosmetic. Leave them as well on pages where the query string carries real state, such as search, filtering or pagination, since those parameters must survive.

Page builders are the third case: some load their own assets with versioned URLs that the filters never see, so you remove a few strings, the audit still fails, and you have spent an afternoon for nothing.

WordPress hosting from WebJi® includes a page cache and AutoSSL, which matter more to real load times than this setting. The plans are on WordPress hosting; if you want the work done for you, the WordPress speed optimization service covers caching, images and core web vitals together. Questions go to support@webji.services, answered 24/7 in Hindi and English with an average first reply under 60 minutes, or through the contact page.

Frequently Asked Questions

How do I remove query strings from WordPress CSS and JS?

Use a plugin toggle such as Perfmatters under Options, General, or add a filter on script_loader_src and style_loader_src that runs remove_query_arg('ver', $src). Then purge the cache and reload.

Does removing query strings make my site faster?

Rarely by a measurable amount. The warning dates from proxies that skipped caching any URL with a question mark. Modern CDNs and browsers cache those URLs, so the change mostly clears an audit item.

Why does my site look unstyled after removing them?

The browser is serving an old cached stylesheet, and the version string that used to force a refresh is gone. Hard refresh with Ctrl and F5 or open a private window. If it stays broken, a file is returning a 404 in the console.

Will the change survive a theme update?

Only if the code sits in a child theme or the Code Snippets plugin. A filter added to the parent theme's functions.php is overwritten at the next update, and the query strings return.

Why are some query strings still there?

The two filters only touch URLs that WordPress generates through its enqueue functions. Assets hardcoded by a plugin or a page builder bypass them, which is why the audit can remain partially failed.

Should I remove query strings from search URLs too?

No. Parameters on search, filter and pagination URLs carry state the page needs. This change is about static CSS and JS file versions, not about rewriting user-facing URLs.

Need help with this?

WebJi® support does it for you — free. Talk to our Jaipur team →