• Resolved rudolfl

    (@rudolfl)


    Hi,

    As per plugin screen, JS excludes combine custom excludes with the ones from “https://github.com/litespeedtech/lscache_wp/blob/dev/data/js_excludes.txt

    So, what is the proper way of modifying those? I found that txt file in my plugin install and edited it by commenting out some defaults with #. Doe snot seem to make any effect (I cleared the cache). Is that the right way? WIll my changes persist between plugin upgrades?

    I want to defer GTM code (yes, I know it is not recommended, but want to try to see how much will speed improves)

    Thanks

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

    (@qtwrk)

    please try remove the line that you want to remove, instead of comment, see how it goes

    Thread Starter rudolfl

    (@rudolfl)

    Hi,

    Still same. This is what I still see in the page source

    <script data-cfasync="false">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-NRLXXV');</script>

    As far as I understand, this means script executes right away. I did a search through files — gtm.js is mentioned in const.default.ini Don’t know if this is relevant

    Plugin Support qtwrk

    (@qtwrk)

    data-cfasync="false"

    this is the key , you can see in code https://github.com/litespeedtech/lscache_wp/blob/75fbc8028b510514228d9a8526c0e9f91cb2a0fc/src/optimize.cls.php#L884

    if it has this attribute and to be false, it will bypass

    Thread Starter rudolfl

    (@rudolfl)

    Ah, I see.

    This attribute is added by the GTM plugin that inserts the code. Is there a way in LS Cache to tell it to ignore this attribute? Otherwise I will have to modify the code of GTM plugin

    Rudolf

    Plugin Support qtwrk

    (@qtwrk)

    function remove_cfasync_attribute( $content ) {
    return str_replace( 'data-cfasync="false"', '', $content );
    }
    add_filter( 'litespeed_buffer_before', 'remove_cfasync_attribute', 0);

    maybe you can try this , it should remove that data-cfasync from source code before page optm process

    Thread Starter rudolfl

    (@rudolfl)

    Thank you

    I think it worked. Will test for the next few days

    Rudolf

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.