Have you seen WordPress version number as a query string after every CSS and JS file? You are not alone. It is easy to remove that string, even though there is little documentation available in the codex. Please note that it is different from what WP-Minify plugin adds in the minified version of the CSS and JS file. Having the query doesn’t allow certain browsers to cache the CSS and JS files. Once removed, it offers performance benefits on those browsers. Moreover, who would want to expose the version of WordPress at the end of these files?
Locate The File
To remove the string from your theme related files, fire up the theme editor and open the
functions.php file or
header.php file. It varies depending on the theme. If you’d want to remove the query string on CSS and JS files derived from any plugin, then please switch to the plugin editor and open the appropriate plugin file. Again it varies greatly depending on the plugin, but not so much as with the themes.
The version of WordPress is inserted by two functions…
Let’s Do It
In both functions, only the first parameter is required. The remaining four parameters are optional. The fourth parameter $ver sets the version number manually or automatically. If it is not defined, then the default value is false. Now to remove the query string from the URL, just change this value to null. That’s it. You’re done.
In some cases such as when you’d want to force CSS changes to “go live” immediately, having the query string in the URL is proven to be beneficial. Even in such a situation, we can setup automatic versioning of JS and CSS files.
Happy Coding. :)