• Thanks for creating the plugin, it really works well.

    Our website shows PageScore A 96%
    https://www.newzealandmotorhome.com

    I have a small issue to respond to the Gtmetrix alert of “Defer parsing of JavaScript”

    I put these 3 js file names into Async JavaScript plugin > Setting Tab > under “Scripts to Defer” field.

    It does not seem to take any effect.

    Here is a screenshot of what I entered

    (I tried to enter full path url, relative URL, neither worked)

    https://pasteboard.co/HvagCexU.png

    When you have time, would you check and let me know what was wrong?

    Thank you for your time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frank Goossens

    (@futtta)

    could be due to your theme (or a plugin) is adding those 3 JS-files late skytower1 (as if after AsyncJS did its job). this is (somewhat) confirmed by the fact that when loading your page without Autoptimize being active (by adding ?ao_noptimize=1 to the URL), the jquery.min.js file isn’t even loaded.

    also; you might want to take a look at why you have PHP-code showing up at the top of your page source:

    
    /**
     * Defer parsing of javascript.
     */
    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 );
    }
    Thread Starter skytower1

    (@skytower1)

    Frank,

    This was added into the functions.php page by myself.
    It does not work.

    I noticed that these 3 js are keeping loaded from header.php
    I then moved them to body section, and added defer tag manually
    It works now.

    Now I have a 97% score.

    Do you have any suggestions about optimizing Fully Load Time?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I noticed that these 3 js are keeping loaded from header.php

    that explains why AsyncJS didn’t pick those up; the scripts are hardcoded in the .php, but the proper way of adding JS is done by registering and enqueueing JS (and CSS). AsyncJS hooks into that queueing mechanism to add the flags.

    Do you have any suggestions about optimizing Fully Load Time?

    Don’t worry too much about fully loaded, focus on “start render” which measures how long it takes for the user to see *something* and “onload” (aka “document loaded”)
    which measures how long it takes for the main resources to load (and finish rendering).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Async JavaScript Plugin – Scripts to Defer not working for me’ is closed to new replies.