Black Friday Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[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!

    GeneratePress 2.0.2
    #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
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.