Archived topic
Remove Query Strings from Static Resources
3 replies · Started by Annalena on February 18, 2018
Hi!
When I test my site on Pingdom I get this message: Remove Query Strings from Static Resources.I wonder if it's safe to paste following code into the code snippet plugin?
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 );
I don't know if it's important to fix this, as my site get about full score in every other aspect, loading in 300 ms. I don't even know what it means to remove query strings?
There was a warning about pasting this code into the function.php as it could mess up the theme, that's why I'm asking you first.
Thank you!
Hi there,
Removing query strings won't make any noticeable difference to your page speed.
It will give you higher scores, but those scores don't mean much - speed means everything.
Removing query strings will also make it your visitors browser doesn't know when a file has changed. That can lead to caching issues where they see the site without updated CSS etc..
That being said, that code looks fine. You can also use a plugin: https://wordpress.org/plugins/query-strings-remover/
Hope this helps :)
Thanks Tom! Great support as usual! 👍
You're welcome :)