Last active
December 14, 2015 09:49
-
-
Save surefirewebserv/5067222 to your computer and use it in GitHub Desktop.
Remove ?ver=xxx from styles and scripts.
This file contains hidden or 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
<?php | |
/** Remove ?ver=xxx from styles and scripts */ | |
function remove_cssjs_ver( $src ) { | |
if( strpos( $src, '?ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} | |
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); | |
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 ); |
+1 What Pippin said.
I agree, and you can also target which file you want to remove the version number, however in my specific situation, the scripts were not being read with the ?ver=xxx attached.
I wouldn't do this on my normal sites...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would not recommend this. The version number (if used correctly) can be very important for ensuring the visitor does not see a cached version: http://pippinsplugins.com/uncached-script-and-style-updates/