Remove query strings on static resources

Developers often add query strings to their theme or plugin files to keep track of versions and to invalidate cache during development. When the query string is changed, it forces the client’s browser to download an updated copy of the stylesheet or script.

Code Snippet

Add the following code snippet to functions.php or through the Code Snippets (or Code Snippets Pro) plugin:

function removeQueryStrings( $src ) {
 if( strpos( $src, '?ver=' ) )
 $src = remove_query_arg( 'ver', $src );
 return $src;
add_filter( 'style_loader_src', 'removeQueryStrings', 10, 2 );
add_filter( 'script_loader_src', 'removeQueryStrings', 10, 2 );


That’s it, you’re done.