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

7 replies3 participantsUpdated by Rose Tyler

  • Avatar: Orna Ohayon
    Orna Ohayon
    Participant

    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
    Participant

    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

    Hello,

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

    Regards

    Avatar: Olga Barlow
    Olga Barlow
    Participant

    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

    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
    Participant

    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

    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

    Hello,

    You’re welcome!

    Regards

Want to reply? Log in, or register with your ThemeForest purchase code, to reply to this topic.

Login / Register