Home Forums WoodMart support forum Website Performance

Website Performance

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

    ckluong3
    Participant

    Hi, I am testing my site’s speed and having some bad score on Defer parsing of JavaScript.

    I found this thread (https://xtemos.com/forums/topic/how-i-get-94100-at-gtmetrix-page-speed-score-the-plugins-code-snippets-used/),
    and it shared some codes to be added into function.php, may I know if this code workable and will this code affect the woodmart theme?

    Please advise, thanks.

    ———————————————————————

    5- Add this code to your (Woodmart child theme) function.php

    // Defer jQuery Parsing using the HTML5 defer property
    if (!(is_admin() )) {
    function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, ‘.js’ ) ) return $url;
    if ( strpos( $url, ‘jquery.js’ ) ) return $url;
    // return “$url’ defer “;
    return “$url’ defer onload='”;
    }
    add_filter( ‘clean_url’, ‘defer_parsing_of_js’, 11, 1 );
    }
    Explanation: The above code simply Defer parsing of JavaScript, Defer parsing JavaScript helps you a lot reduce blocking of page rendering and make it skyrocket fast loading.

    6- Get rid of WordPress meta generator tags, which displays your website’s WordPress version, and all of the other plugins meta generators as well for anyone to see. This can be a security risk for your website but it is easy to remove by using the below function.

    // Remove All Meta Generators
    function remove_meta_generators($html) {
    $pattern = ‘/<meta name(.*)=(.*)”generator”(.*)>/i’;
    $html = preg_replace($pattern, ”, $html);
    return $html;
    }
    function clean_meta_generators($html) {
    ob_start(‘remove_meta_generators’);
    }
    add_action(‘get_header’, ‘clean_meta_generators’, 100);
    add_action(‘wp_footer’, function(){ ob_end_flush(); }, 100);
    7- Another speed factor is to remove Emoji styles and scripts which help increase performance and lower JavaScript and CSS resources.

    // Remove Emoji Styles and Scripts
    remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
    remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
    remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
    remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );

    Attachments:
    You must be logged in to view attached files.
    #63866

    Artem Temos
    Keymaster

    Hello,

    Sorry, it is not our official solution and we are not responsible for it. But as you can see, it worked for that website well.

    Regards

    #63912

    ckluong3
    Participant

    Hi, would like to check what is the official solution for “Defer parsing of JavaScript” as it scored a low grade in gtmetrix.com?

    Please advise, thanks.

    #63927

    Artem Temos
    Keymaster

    Our theme’s scripts are already deferred and loaded in the footer. The problem is with all other scripts on your website loaded by all plugins and WordPress core.

Viewing 4 posts - 1 through 4 (of 4 total)