1. Remove Query Strings from Static Resources with Code
You can easily remove query strings from your assets with a few lines of code. Simply add the following to your WordPress theme’s functions.php
file.
function remove_query_strings() {
if(!is_admin()) {
add_filter('script_loader_src', 'remove_query_strings_split', 15);
add_filter('style_loader_src', 'remove_query_strings_split', 15);
}
}
function remove_query_strings_split($src){
$output = preg_split("/(&ver|\?ver)/", $src);
return $output[0];
}
add_action('init', 'remove_query_strings');
Important: Editing the source code of a WordPress theme could break your site if not done correctly. If you aren’t comfortable doing this, please check with a developer first