Always Forward

Remove query strings from static resources error solution

Notice

This post was auto-translated with Google Translate, and I will proofread it in the upcoming weeks.
This post is over 5 years old, and may not reflect the author’s current view.

With this article, I started to explain the errors in Gtmetrix or the things that need to be fixed one by one. In this article, I will talk about the solution of the error “remove query strings from static resources” in English. Our goal here is to extract query strings from static sources, that is, from static documents, from links in our files. To put it more simply;

remove-query-strings-from-static-resources-cozumu

We will edit these queries with the question mark above. Because the version information after the question mark is something that slows down the site and therefore lowers our pagespeed score. In the picture below, we can examine this url structure in more detail.wordpress-sorgu-dizelerini-kaldirmak

Solution

Open your theme’s functions.php file and add the following code to a suitable place before the ?> tag and save the file.

<pre class=”font:arial lang:default decode:true crayon-selected” style=”color: #666666;”>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 );</pre>

I would like to remind you that in some themes, you may need to open another file called custom-functions.php instead of functions.php file. Because the theme I use works in this way, so I thought I’d tell you. Although not every item is solved so easily in Gtmetrix, if you pay attention to these items, you will provide a better user experience as you increase the site speed. These are sure to bring you good rankings on Google, being a brand, etc. I hope you pay attention to these little details.

In this article, I explained what the remove query strings from static resources error is and how to solve it. If there is a place where you are stuck, indicate it in the comments. Also, if you have any comments on the subject, please let me know. See you on another Gtmetrix error solution.

Kerem Mete

Hi, I am a seasoned SEO specialist with 10 years of experience driving organic growth and developing effective SEO strategies. Currently, I am working as a Sr. SEO Manager in Digitas in the UK. For more details, check out my about me page.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button