Defer parsing of JavaScript - by designerobot

This topic has 5 replies, 2 voices, and was last updated 5 years, 2 months ago ago by Olga Barlow

  • Avatar: designerobot
    designerobot
    Participant
    September 15, 2019 at 03:46

    Hello, I’ve a problem with all my websites where I’m using your beautiful theme.
    If I test the website with the GTmetrix tool, the result is always that I need to “Defer parsing of JavaScript”.
    To do it I have two possibilities:

    1) install and active “Async JavaScript” plugin
    or
    2) insert this code in function.php

    function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' defer ";
    }
    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

    Well, whatever process I use, I solve the problem (as you can see by the links in PVT). However, with both methods, there is a problem: the buttons on the Portfolio page stop working.
    How to solve the problem? Maybe could I exclude the Portfolio page only in some way?

    Please, contact administrator
    for this information.
    4 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 16, 2019 at 17:18

    Hello,

    You may try cache plugin and JS minification+combination in one and after that try to defer them.
    Let me know if it does not work for you.

    Regards

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 16, 2019 at 17:19

    P.S. clean_url function is deprecated https://developer.wordpress.org/reference/functions/clean_url/

    Regards

    Avatar: designerobot
    designerobot
    Participant
    September 17, 2019 at 15:55

    Hello,

    How to “try cache plugin and JS minification+combination in one” and after how to “defer them”.

    What plugin (or code) do you suggest to use in both cases?

    I’m not sure to have understood how to do it.

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    September 18, 2019 at 11:29

    Hello,

    Use cache plugin for these purposes: W3 Total cache, WPRocket or any other that includes these options, for example, http://prntscr.com/p7oikg

    Regards

  • Viewing 5 results - 1 through 5 (of 5 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.