Remove quary strings - by Orna Ohayon - on WordPress WooCommerce support

This topic has 8 replies, 3 voices, and was last updated 6 years, 4 months ago ago by Rose Tyler

  • Avatar: Orna Ohayon
    Orna Ohayon
    Participant
    July 16, 2018 at 13:05

    Hello,

    I have cheke my site in pingdom.com
    and get: https://snag.gy/WlUODb.jpg
    so, I need to Remove the query string and encode the parameters into the URL

    can I add the cod in functions.php in my wp-admin?
    is it will be enough or I need to do it also on CPanel?

    //remove quary strings
    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 );

    Best Regards
    Orna

    7 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    July 17, 2018 at 15:11

    Hello,

    Use the code below, your code conflicts with the google fonts

    // Remove query string from static files
    function remove_cssjs_ver( $src ) {
    
        // Do not do it for revslider and essential-grid.
        if ( strpos( $src, 'revslider' ) || strpos( $src, 'essential-grid' ) ) return esc_url( $src );
    
        if( strpos( $src, '?ver=' ) )
            $src = remove_query_arg( 'ver', $src );
        return esc_url($src);
    }
    
    add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
    add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

    Regards

    Avatar: Orna Ohayon
    Orna Ohayon
    Participant
    July 18, 2018 at 21:33

    Hello,

    I need to add it on functions.php in the cPanel?

    Regards

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    July 19, 2018 at 14:20

    Hello,

    Connect to your server using FTP or cPanel and add the code in the child theme functions.php file.

    Regards

    Avatar: Orna Ohayon
    Orna Ohayon
    Participant
    July 19, 2018 at 14:46

    Hello Olga,

    I did it but the rank sow me now
    72 Remove query strings from static resources

    https://snag.gy/MVbpxe.jpg

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    July 19, 2018 at 15:07

    Hello,

    I see 92 score http://prntscr.com/k8geec where all the strings are plugins strings. Any string directly from our theme files.

    Regards

    Avatar: Orna Ohayon
    Orna Ohayon
    Participant
    July 19, 2018 at 20:32

    Hello,

    I think it changed again after you delete the cache plugin

    It’s o.k. now as you say (:
    Many thanks

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 20, 2018 at 07:33

    Hello,

    You’re welcome!

    Regards

  • Viewing 8 results - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.