21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
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, 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.

For WordPress owners chasing a PageSpeed audit: what the ?ver= value does, when removing it helps, the two removal methods, and the unstyled-page failure.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
5 min
Sections
8
Updated
14 Nov 2026
Written by
WebJi® team

What is a query string on a WordPress CSS or JS file?

It is the ?ver= value WordPress appends to enqueued CSS and JavaScript URLs, so a stylesheet loads as style.css?ver=6.8 instead of plain style.css. The value is a cache buster: when a theme or plugin updates, the version changes and browsers fetch the new file instead of serving a stale copy.

  • Where it comes from: wp_enqueue_style() and wp_enqueue_script() accept a version argument that becomes the query string.
  • What it protects: after an update, visitors get the new CSS instead of an old browser-cache copy.
  • What it is not: a tracking parameter — removing it changes nothing about the file itself.

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

The "remove query strings from static resources" warning comes from an older era of proxies and CDNs that skipped their cache for any URL containing a question mark; most modern CDNs cache query-string URLs by default, and browsers always have. On a current stack, stripping ?ver= usually moves the score by a point or two and changes measured load time by nothing.

Do not confuse the audit with "eliminate render-blocking resources", which is about when CSS and JS execute, not about their URL. Query strings affect cache-hit rates on intermediaries; render-blocking affects the browser's critical path. Fixing one does nothing for the other.

The removal is still worth doing when your host, CDN or a corporate proxy is configured to ignore query-string URLs — check that before spending time on it.

How do you remove them with a plugin?

The click path is short, and it is the safer option for anyone who does not want to edit theme files: install a tool with a remove-query-strings toggle and clear the caches afterwards.

  1. Install Perfmatters, or the free "Remove Query Strings From Static Resources" style plugin from the WordPress plugin directory.
  2. For Perfmatters: Settings → Perfmatters → Options tab → General section, switch on Remove Query Strings, save.
  3. For the free plugin: nothing to configure — activating it is the whole step.
  4. Clear the page cache and any CDN cache, then reload the site in a private window.

If you already run LiteSpeed Cache or another caching plugin, check its settings first: it may offer the same toggle, and two tools doing the same job can conflict.

How do you remove them with a functions.php filter?

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

function webji_strip_ver( $src ) {
    if ( strpos( $src, 'ver=' ) ) {
        $src = remove_query_arg( 'ver', $src );
    }
    return $src;
}
add_filter( 'script_loader_src', 'webji_strip_ver', 15 );
add_filter( 'style_loader_src', 'webji_strip_ver', 15 );
  1. Open Appearance → Theme File Editor and confirm you are editing the child theme, not the parent — or add the snippet through Code Snippets.
  2. Paste the function and the two filters at the end of the file; a well-formed functions.php has no closing PHP tag.
  3. Save and reload any page. A white screen means you edited the parent theme or missed a semicolon — restore from backup and use the plugin method instead.

How do you verify the change with one command?

Purge the cache first — otherwise you are reading old HTML — then count the remaining versioned URLs on the homepage.

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

Why does the site lose its styling after removing them?

Because the browser is holding an old cached stylesheet and the version string that used to force a refresh is gone — press Ctrl+F5 or open 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 (filemtime) rather than by deleting the version — otherwise a behind-the-scenes CSS edit that does not bump the plugin version reaches returning visitors late. The child theme guide shows where such filters belong.

When should you leave the query strings alone?

Leave them when your CDN already caches query-string URLs — the warning is then cosmetic — and on any URL where the query string carries real state, such as search, filtering or pagination. Page builders are the third case: some load their own assets with versioned URLs the filters never see, so you remove a few strings, the audit still fails, and you have spent an afternoon for nothing.

For load time that visitors actually feel, caching, images and core web vitals matter more than the ?ver= audit. WordPress hosting at WebJi® ships with a WP install wizard, daily backups, staging tools and a global CDN; if you would rather have the work done, the WordPress speed optimisation service covers all three fronts together. Questions go to support@webji.services — 24/7 in Hindi and English, average first reply under an hour.

FAQ

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 every cache layer and reload in a private window.

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 rather than shifting load time.

Why does my site look unstyled after removing them?

The browser is serving an old cached stylesheet, and the version string that forced a refresh is gone. Hard-refresh with Ctrl+F5 or open a private window. If it stays broken, a file is returning a 404 — read the path in the browser 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 quietly return.

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.

Last editorial update: 15 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.