How to remove query string wordpress

If you check your wordpress website in Google page speed or other speed test service, you may probably find one of the parameter that suggest you to remove query string from static resources.

There are many factor that affects your website loading time and Google speed test consider all that factors. According to their advisers, remove the query string from static resource  like style-sheet (CSS), javascript (JS) will reduce the loading time.

There are two ways for you to do it.

1. Using Code

Copy and paste the code below to your functions.php file. You can choose edit the file by using the editor in your hosting or via file manager.

// Remove query string from static files
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

2. Plugin

If you don’t know anything about coding, just install the this plugin and you are done.

And this is the result after I remove query string for my website.

Before.

After

Now you can use three trusting tool for testing your website loading time performance again.

Don't be shellfish...