...
Tutorials, Wordpress

How to Remove Query Strings From Static Resources in WordPress?

18 March 2019

You can also remove query strings from static resources in WordPress your assets with code. Simply add the following to your WordPress theme’s functions.php file.

Removing query strings from static resources improves website speed.

function _remove_script_version( $src ){ 
$parts = explode( '?', $src ); 	
return $parts[0]; 
} 
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); 
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Leave a Comments