remove query strings from static resources in wordpress

Remove Query Strings from static resources in WordPress

Punit Makwana Performance Leave a Comment

”Remove query strings from static resources” a common statement which you find while checking the loading time of your site in GTmetrix or any other related tool. We all know that Google is now using page speed to rank pages in their search results, so you must have a closer look at the all the aspects which are slowing down your site.

You can use Google Page Speed, Pingdom Tool or GTmetrix to find out the parameters which are affecting the speed of your site and take action to rectify those issues. Today in this post, we will take remove query strings from static resources a very common parameter which affects loading speed of a site.

gtmetrix query string

You can’t cache a link with a “?” in its URL. The query string is a method used by developers of WordPress tools to pass the content values or to carry the version detail.

Remove query strings from static resources

Now, the question is how to remove query strings from static resources to make sure that it is not affecting the loading time of your site. Different experts have a different solution to achieve this. Let’s look at some of the solutions with proven track record.

#1. Using functions.php

Solution number one is to use the code given below, open functions.php folder of your theme put code given below in the file save it, clear cache and check if it works.

function _remove_script_version( $src ){
$parts = explode( '?ver', $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. W3 Total Cache

If you are using W3 Total Cache plugin on your WordPress site, go to Browser cache settings and uncheck “Prevent caching of objects after settings change” and save your settings. This should make sure to remove the query strings from static resources served from your domain.

w3tc prevent query string

#3. Remove Query Strings From Static Resources

If the above-mentioned methods don’t work for you, there is a really useful plugin which helps you to remove query strings from static resources.

This is a very simple plugin, just install and active the plugin and that’s all. There are no additional settings which you need to take care of to remove query strings from static resources.

 

This plugin is already downloaded more than 25000 times with five-star rating, so I’m sure this plugin worked for most of the users.

#4. Query Strings Remover

Query Strings Remover is another WordPress plugin that can help you to remove query strings from your static resources like CSS and JavaScript files.

This is a very simple plugin to use, just install the plugin and activate. After the activation don’t forget to clear the cache so that you can check how this plugin improves the overall performance of your site.

#5. Speed Booster Pack

Speed Booster Pack is a very useful WordPress plugin that can help you to do a lot of things to improve the performance of your site and make it quick as well as SEO friendly.

Other than removing query strings from static resources, this plugin does a lot of things such as

  • Eliminate external render-blocking javascript and CSS in above-the-fold content
  • Moves scripts to the footer to improve page loading speed
  • Loads CSS asynchronously to render your page more quickly and get a higher score on the major speed testing services.
  • Minify and inline all CSS styles and move them to the footer to eliminate external render-blocking CSS and optimize CSS delivery.
  • Lazy loads images to improve page load times and save bandwidth.
  • Changes image compression level to keep file sizes smaller.

Conclusion

The speed of your site is not only important from the search engine’s point of view but also from the user’s experience point of view. No one would like to visit a site which takes minutes to load a page. Make sure you look at all the aspects which are responsible for slowing down your site and rectify.

Remove query strings from static resources, an issue which can be resolved and once it is resolved it will definitely bring in a positive effect to your site.

The following two tabs change content below.
Punit Makwana is the founder of VScripts and a passionate blogger. When he’s not writing and brainstorming content ideas, this Mumbai native spends his time reading books, hanging out with his friends and watching movies

Leave a Reply