Return to Snippet

Revision: 74773
at December 19, 2018 05:48 by cerxx


Initial Code
function vc_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );

Initial URL
https://codebeer.ru/ubrat-versiyu-cssjs-fajlov-v-wordpress/

Initial Description
By default, WordPress adds the? Ver = [version] parameter to the end of the address of all connected CSS and JavaScript files. The use of versioning adds a convenient mechanism for monitoring the state of the browser’s cache. After modifying the files, in order for the browser to automatically download the actual versions of CSS or JavaScript, the webmaster simply changes the numeric index ver for the connected file.

Despite the obvious advantages, this method has its drawbacks. One of the main reasons why developers refuse to use versions is that not all proxy servers and CDNs support file caching, at the end of which addresses the ver parameter is specified.

In order to remove ver from the connection string, you need to add the following code to the content of your theme's functions.php file:

Initial Title
Remove version of CSS / JS files in WordPress

Initial Tags
wordpress

Initial Language
PHP