Remove version from css & js files in WordPress

In this post I will show how we can remove version from CSS & JS files in WordPress. Many css and js files in the WordPress have the WordPress version number appended after the file names.

Why version is appended to css and js files?

Let’s say you are developing or updating a site and want to present it to your clients. But clients’ browser cache does not let them see any of the changes you made and your clients’ see the old looks.

Therefore, there is a simple solution, versioning mechanism. Adding parameters at the end of the css or js file name will force the browser reload the file, because it is treated as a new file.


WordPress has its own built-in versioning mechanism and it automatically adds the version number to the css and js files when the theme loads those css and js files.

Why do we need to remove version from css and js files?

To improve the speed of website as much as possible we need to remove query strings from css and js files.

When we analyze site’s page using any page speed analyzer, such as, Google’s Page Speed, YSlow or Pingdom, we are very likely to see suggestions to remove query strings from css and js files.

This is a problem as many proxies will not cache the resources if it has a query string in the URL.

Removing version from css and js files

Simply add the below code to your theme’s functions.php file:

function remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
add_filter( 'style_loader_src', 'remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'remove_wp_ver_css_js', 9999 );

Thanks for reading.

Related posts

One Thought to “Remove version from css & js files in WordPress”

Leave a Comment