Remove Query Strings from static resources in WordPress

“Remove Query Strings from static resources” is one of the major suggestions that appear to increase the performance of your website. Here comes the solution to this problem. We can resolve this issue by editing some code in files as shown below

What are the Query Strings in WordPress?

remove query strings from static resources

The URLs which contains “?” or “&” are called Query Strings. For example https://itgiggs.in/post?ver=2.3 as we can see the url is not proper, that’s why it creates problem in caching the files. Hence, the website goes slow

Check your website on speed test tools like GTmetrix or Pingdom. You will definitely find URLs with Query Strings (? or &).

How to Remove Query Strings form Static Resources like CSS & JavaScript?

how to remove query strings from static resources

Do you Know ?

How to optimize your wordpress website ?

To Remove Query Strings form Static Resources like CSS & JavaScript, you only need to add the following code in your functions.php file.

//* 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 );

Also, There are many plugins available on WordPress Website. You can use those plugins if you do not want to code.

Should We Remove Query Strings from Static Resources?

Query Strings prevent caching of some files like CSS and JavaScript on Servers  which results in a very slow loading website. So, we should remove these Query Strings (which content “?” or “&” in their URLs) from Static Resources to enable caching on Servers.

See Also : Some online tools to test your website performance

Reference urls :https://technumero.com/remove-query-strings-from-static-resources/

Add a Comment

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