Remove ?ver Query String Without Plugin in WordPress

Remove Query String Without Plugin to improve caching for your CSS and JS files and boost your PageSpeed score. Here’s how to do it with a simple tweak.

Step 1: Add the Query String Removal Code

Add this to your child theme’s functions.php:


// Remove ?ver query string from static resources
function qdt_remove_query_string( $src ) {
  if( strpos( $src, ‘?ver=’ ) )
    $src = remove_query_arg( ‘ver’, $src );
  return $src;
}
add_filter( ‘script_loader_src’, ‘qdt_remove_query_string’, 15, 1 );
add_filter( ‘style_loader_src’, ‘qdt_remove_query_string’, 15, 1 );

How It Works

This function strips the ?ver version query string from static resource URLs so they can be cached more effectively by browsers and CDNs.

Why Remove Query String Without Plugin?

Removing ?ver query strings helps improve your site’s caching behavior, reduces HTTP requests, and boosts your PageSpeed score.

Common Mistake

If you frequently update CSS or JS files, the ?ver parameter ensures browsers load the latest version. Without it, you’ll need to clear caches manually when making changes.

Pro Tip

Add this tweak in your child theme’s functions.php so it stays safe after theme updates.

Related Snippet

If you liked this, check out my guide on disabling WP Cron without a plugin in WordPress.

Leave a Comment