Support » Plugin: LiteSpeed Cache » Excluded JS also not deferred?

  • Resolved slr1979

    (@slr1979)


    Hi

    When excluding js from minification/combining these files are also not deferred which causes a low score on GTMetrix for ‘Defer parsing of JavaScript’. Is this intentional? Could excluding from combining and minifying be separated from deferment?

    I currently use the code below for some of my excluded js but could this be expanded to accommodate scripts on the list of exclusions as I also exclude all core WP js for compatibility and I don’t really want to list every handle for those?

    function defer_js_scripts( $tag, $handle, $src ) {
      $defer = array( 'js1', 'js2', 'js3');
      if ( in_array( $handle, $defer ) ) {
         return '<script id="'.$handle.'" src="' . $src . '" defer></script>' . "\n";
      }
      return $tag;
    } 
    add_filter( 'script_loader_tag', 'defer_js_scripts', 10, 3 );

    Also, is it safe to delete the htaceess backups as indicated in the github post below as they still exist on my server?

    https://github.com/litespeedtech/lscache_wp/issues/221

    Many thanks for your time

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    they are supposed to be have different excluding area

    https://i.imgur.com/4w0nqf1.png

    are you sure the defer exclude list is empty ?

    Best regards,

    Thread Starter slr1979

    (@slr1979)

    Yes the defer exclude list is empty

    https://tinyurl.com/y5hjhu5j

    GTMetrix reports that the files on the js excludes list are not deferred.

    The same issue also occurs when not using LS CDN for js also.

    Please advise

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Could you please provide the report number ?

    You can get it in toolbox -> report , click “send to LiteSpeed”

    Best regards,

    Thread Starter slr1979

    (@slr1979)

    Hi @qtwrk

    Report no: TVPJKCCV

    Awaiting further instructions!

    Best regards

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Some of the JS files are not even in the JS exclude list.

    could you please try export your current setting , reset to default , then only to enable defer JS, and see if they are get deferred ?

    Best regards,

    Thread Starter slr1979

    (@slr1979)

    Hi,

    I performed the above and all the js are deferred with only defer js enabled.

    As a test, I added the JS Excludes and enabled JS combine/JS minify. The files in the JS Excludes list were not deferred with Load JS Deferred on and nothing in the JS Deferred Excludes.

    When I disable JS combine/JS minify the files in the JS Excludes list are still not deferred. When I clear the JS Excludes list all js is deferred.

    The same is true when I reimported my settings from import. So there appears to be an issue with the JS Excludes list.

    I have reimported my current settings for the time being as this is a live site.

    Please advise.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    I have managed to reproduce the error.

    Please wait for fix…

    Best regards,

    Plugin Support Hai Zheng⚡

    (@hailite)

    Hi @slr1979,

    Thanks for your report. This is fixed in v3.4.1-rc3. Please try beta test on it from Toolbox menu.

    Thread Starter slr1979

    (@slr1979)

    Hi @hailite @qtwrk

    Many thanks for your time and the fix. I can confirm that the issue has been resolved.

    Will this be merged into the next release shortly?

    Best regards

    Plugin Support Hai Zheng⚡

    (@hailite)

    You are most welcome.

    Yes it will.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Excluded JS also not deferred?’ is closed to new replies.