Remove query strings from static resources
If you are looking for the option to improve your wordpress website performance I will definitely recommend to go through post Speed up your wordpress site to load fast. However, if you are only concerned to Remove query strings from static resources your are at right place.
I will let you know the two quick and easy ways to score high against “Remove query strings from static resources” on GTMetrix. So without wasting any further time here are those two tricks:
1. Paste below code in your Theme Functions
All you need to do is login to your wordpress site » Go to dashboard » Appearance » Editor » Select Theme Functions (functions.php). This code is pretty safe and will not break anything but still it is a good idea to take backup of your functions.php before doing any modification. You can paste this code anywhere in your functions.php file but try add it at bottom.
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 ); |
Once done click on update file and go to GTMetrix to check score against Remove query strings from static resources. If you are using any caching plugin like W3 Total cache, do clear the cache before you attempt to check the score.
The above method will definitely give boost you score against Remove query strings from static resources but can not handle the external items that are still blocking you to reach 100%. Please read the second to get higher score.
2. Use CloudFlare
To gain even higher score I suggest to use CloudFlare cdn. You can once again go through post Speed up your wordpress site to load fast to see how CloudFlare can be setup for your wordpress site. ( NOTE : Recently CloudFlare update its website and changed some of the navigation so the screenshots given in the above article may not exactly match if you create an account today. )
Once you have setup the CloudFlare login to your account and select your domain. After that click on box “Caching” and select Caching Level “No Query String”
Once done just check your score against Remove query strings from static resources. You will be surprised to see boost.
Additional Resource
If you are interested to try different option you may wish to try plugin Remove Query Strings From Static Resources
I have checked my website and it also suggest me to remove these kind of things. But I wonder does it really hurt the website speed or just a point that need to remove.
Added the code and it resulted in a 500 error – now the site is down. No idea how to fix it. Any ideas on how to UNDO this? Have deleted from the function.php file, and still not resolved…
If this has still not fixed, please use the ftp account to remove the code you have added to your function.php and upload the file after removing the code, this will fix the issue.