How to know which code to use? (Removing Query Strings)
-
So I’ve researched how to remove query strings to speed up my site by editing the .PHP file and it seems every recommendation gives different code to use to supposedly fix the same problem.
Why is this?
Which code should I use out of the two that I found?
1.
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 );2.
//* TN – Remove Query String from Static Resources
function remove_css_js_ver( $src ) {
if( strpos( $src, ‘?ver=’ ) )
$src = remove_query_arg( ‘ver’, $src );
return $src;
}
add_filter( ‘style_loader_src’, ‘remove_css_js_ver’, 10, 2 );
add_filter( ‘script_loader_src’, ‘remove_css_js_ver’, 10, 2 );
- The topic ‘How to know which code to use? (Removing Query Strings)’ is closed to new replies.