How to remove query strings from WordPress resource URLs

This code is removing query string arguments from the resource URLs, javascripts and style sheets, that are denote the version of your WordPress or plugin that you are using.
A must for all WP installations

function _remove_script_version( $src ){
    $parts = explode( '?ver', $src );
        return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Source: https://kinsta.com/knowledgebase/remove-query-strings-static-resources/

Scroll to Top