Remove style & script versions from WordPress assets

Be careful, this might cause caching issues on your site. If you have a proxy caching system set up, your changes on your assets may not be reflected to the site.

function _remove_script_version( $src ){
	$parts = explode( '?', $src );

	if ( substr( $parts[0], 0, strlen( site_url() ) ) == site_url() ) {
		return $parts[0];
	}
	return $src;
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );Code language: PHP (php)

Posted

in

,

by

Tags:

Comments

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.