Created
May 7, 2014 13:56
-
-
Save cezarpopa/13564aaa061e33a44f18 to your computer and use it in GitHub Desktop.
Remove query strings from static resources like CSS & JS files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
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