How to Remove Version from Style and Script From Page Source?

Have you ever checked your page source? If you have seen your page source, you may notice version info in ?ver=x.x.x format. It represents the theme or WordPress or plugins version.

You can just test it now. Visit your homepage and View Page Source. You will see a lot of style and scripts having version numbers. Something like the following codes. 

				
					<link rel='stylesheet' .../style.min.css?ver=5.7.2' type='text/css' media='all' />
<link rel='stylesheet' .../style.min.css?ver=2.3.1' type='text/css' media='all' />
<link rel='stylesheet' .../theme.min.css?ver=2.3.1' type='text/css' media='all' />
<link rel='stylesheet' .../dashicons.min.css?ver=5.7.2' type='text/css' media='all' />
<link rel='stylesheet' .../admin-bar.min.css?ver=5.7.2' type='text/css' media='all' />
				
			

Let’s see how easily you can remove the version from style and script. 

Login to your Cpanel or FTP server. Navigate to your active theme directory and search function.php file. Open this function.php file via text or code editor. Now copy and paste the following code inside your function.php file. 

Save the file and it will hide all version numbers from style and script.

				
					/** Remove Version Query Strings from Scripts/Styles **/
add_filter('script_loader_src', 'jltwp_adminify_remove_script_version', 15, 1);
add_filter('style_loader_src', 'jltwp_adminify_remove_script_version', 15, 1);

/** Remove Query Strings from Scripts/Styles **/
function jltwp_adminify_remove_script_version($src)
{
    $parts = explode('?ver', $src);
    return $parts[0];
}

				
			

If you know nothing about code, then this second method is for you. Install WP Adminify plugin first.

You will see a new menu in your dashboard called WP Adminify or check this WP Adminify Tweaks option. Click on this menu and navigate to tweaks > Head option. Search for the Remove Version from Style and Script option and enable it. This will hide all version info from style and script. 

remove version from style and script
August 27, 2021
Head Tips and Tutorials
Was this article helpful?

© 2021-2024 - Adminify | All rights reserved

WP Adminfy accepted payment methods