Skip to content

Instantly share code, notes, and snippets.

@cezarpopa
Created May 7, 2014 13:56
Show Gist options
  • Save cezarpopa/13564aaa061e33a44f18 to your computer and use it in GitHub Desktop.
Save cezarpopa/13564aaa061e33a44f18 to your computer and use it in GitHub Desktop.
Remove query strings from static resources like CSS & JS files.
/**
Remove query strings from static resources like CSS & JS files. This plugin will improve your scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.
*/
function _remove_query_strings_1( $src ){
$rqs = explode( '?ver', $src );
return $rqs[0];
}
function _remove_query_strings_2( $src ){
$rqs = explode( '&ver', $src );
return $rqs[0];
}
add_filter( 'script_loader_src', '_remove_query_strings_1', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings_1', 15, 1 );
add_filter( 'script_loader_src', '_remove_query_strings_2', 15, 1 );
add_filter( 'style_loader_src', '_remove_query_strings_2', 15, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment