0

How do I fix this site speed recommendation with wordpress to remove query strings from static resources.

I have some Resources with a "?x54532" on the final of the link including images, js, css....

     des/css/dashicons.min.css?x54532'
wp-includes/css/admin-bar.min.css?x54532
wp-content/uploads/2017/12/favicon.png?x54532"

I have 131 links with that query string"?x54532"

3 Answers 3

1

The advice "Remove query strings from static resources" is no longer relevant.

The advice originally came from Google PageSpeed but they dropped the recommendation in 2014. By that point, GTMetrix and Pingdom had already adopted all the PageSpeed recommendations and they've not yet updated their testing criteria to match the new PageSpeed recommendations.

You can go direct to Google PageSpeed to test your website here:

https://developers.google.com/speed/pagespeed/insights/

You will notice that "Remove query strings from static resources" is not a PageSpeed recommendation. The reason Google dropped it is because proxy servers like Squid have been caching static resources with query strings for about a decade already.

There are other good reasons why you should ignore the query string advice, not least that GTMetrix doesn't score your website down even with a 0% score:

https://sirv.com/help/resources/remove-query-strings-from-static-resources/

Instead, prioritise your time to fix the important PageSpeed recommendations that will make your pages load faster.

Sign up to request clarification or add additional context in comments.

Comments

0

Place this in your theme's functions.php file or create a plugin file.

function remove_script_style_version( $src ) {
    if ( strpos( $src, 'ver=' ) ) {
        $src = remove_query_arg( 'ver', $src );
    }
    if ( strpos( $src, 'x54532' ) ) {
        $src = remove_query_arg( 'x54532', $src );
    }
    return $src;
}
add_filter( 'style_loader_src', 'remove_script_style_version', 1000 );
add_filter( 'script_loader_src', 'remove_script_style_version', 1000 );

Comments

0
// Remove Query String
function nerodev_remove_query_string($src) {
    $parts = explode('?ver=', $src);
    return $parts[0];
}
add_filter('script_loader_src', 'nerodev_remove_query_string', 15, 1);
add_filter('style_loader_src', 'nerodev_remove_query_string', 15, 1);

Source is here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.