Remove version from css & js files in WordPress

In this post I will show how you can remove version from CSS & JS files in WordPress. Almost all css and js files in the WordPress have the WordPress version number appended after the file names or using a query string. Having query string with the URL browser does not cache the file because the file is treated as dynamic file.

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.

So the change which you to your css or js file is not reflecting in the browser, hence browser is not able render the latest looks of the UI.

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 or dynamic file and browser will not cache the 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 you 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. Remember if you update your theme then the change will be overwritten. So it is always good idea to create a child theme and add the change into child 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 );

Hope you got an idea how to remove version from query string in WordPress.

3 thoughts on “Remove version from css & js files in WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *