[Resolved] Remove Query Strings from Static Resources

Home Forums Support [Resolved] Remove Query Strings from Static Resources

Home Forums Support Remove Query Strings from Static Resources

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #499737
    Annalena

    Hi!

    When I test my site on Pingdom I get this message: Remove Query Strings from Static Resources.I wonder if it’s safe to paste following code into the code snippet plugin?

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

    I don’t know if it’s important to fix this, as my site get about full score in every other aspect, loading in 300 ms. I don’t even know what it means to remove query strings?

    There was a warning about pasting this code into the function.php as it could mess up the theme, that’s why I’m asking you first.

    Thank you!

    #499930
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Removing query strings won’t make any noticeable difference to your page speed.

    It will give you higher scores, but those scores don’t mean much – speed means everything.

    Removing query strings will also make it your visitors browser doesn’t know when a file has changed. That can lead to caching issues where they see the site without updated CSS etc..

    That being said, that code looks fine. You can also use a plugin: https://wordpress.org/plugins/query-strings-remover/

    Hope this helps πŸ™‚

    #500367
    Annalena

    Thanks Tom! Great support as usual! πŸ‘

    #500788
    Tom
    Lead Developer
    Lead Developer

    You’re welcome πŸ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.