Remove Query Strings Without Plugin to boost your WordPress site speed and improve caching. Here’s how to do it manually with a simple functions.php tweak.
Step 1: Add the Query Strings Remove Code
Add this code to your child theme’s functions.php:
function qdt_remove_query_strings($src) {
if( strpos($src, ‘?ver=’) )
$src = remove_query_arg(‘ver’, $src);
return $src;
}
add_filter(‘script_loader_src’, ‘qdt_remove_query_strings’, 15, 1);
add_filter(‘style_loader_src’, ‘qdt_remove_query_strings’, 15, 1);
How It Works
This Remove Query Strings Without Plugin snippet removes the version query string (?ver=) from your CSS and JS URLs so browsers can cache them more efficiently.
Why Remove Query Strings Without Plugin?
By removing query strings, static files like stylesheets and scripts can be cached by CDNs and browsers without issues. This means faster load times and better caching scores.
Common Mistake
Some plugins rely on version query strings for cache busting. Always test your site to make sure removing them doesn’t break your layout or scripts.
Pro Tip
Use a child theme for this Remove Query Strings Without Plugin tweak to make sure your changes stay safe after theme updates.
Related Snippet
If you liked this, check out my guide on disabling emojis without a plugin in WordPress.