• Resolved Jamie Burchell

    (@jamieburchell)


    Run in to a problem with the “defer” attribute being removed from my scripts on one of my websites.

    When W3TC is disabled, both scripts have the defer attribute:

    <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=X&amp;ver=2.0.2" id="gforms_recaptcha_recaptcha-js" defer="defer" data-wp-strategy="defer"></script>

    <script type="text/javascript" src="https://example.com/app/plugins/gravityformsrecaptcha/js/frontend.min.js?x39172&amp;ver=2.0.2" id="gforms_recaptcha_frontend-js" defer="defer" data-wp-strategy="defer"></script>

    When W3TC is enabled, the minified version has the attribute removed:

    <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=X&amp;ver=2.0.2" id="gforms_recaptcha_recaptcha-js" defer="defer" data-wp-strategy="defer"></script>

    <script  src="https://example.com/app/cache/minify/e2eea.js?x39172"></script>

    This causes a problem, since the e2eea script requires the reCAPTCHA library.

    Curiously, on one of my other websites this is not happening:

    When W3TC is enabled, the minified version has a single “defer” attribute (preserved):

    <script src="https://www.google.com/recaptcha/api.js?render=X&amp;ver=2.0.2" id="gforms_recaptcha_recaptcha-js" defer data-wp-strategy="defer"></script>

    <script  defer src="https://example.co.uk/app/cache/minify/e2eea.js?x14114"></script>

    As far as I can tell, the W3TC configurations are pretty much the same for both websites:

    diff broken working
    67c67
    < "lazyload.enabled": true,
    ---
    > "lazyload.enabled": false,
    1078,1080c1078,1080
    < "page": "w3tc_minify",
    < "_wpnonce": "e692661fe3",
    < "_wp_http_referer": "\/wp\/wp-admin\/admin.php?page=w3tc_minify&w3tc_message=68ee51307695c&w3tc_note=flush_all",
    ---
    > "page": "w3tc_general",
    > "_wpnonce": "beaaf92399",
    > "_wp_http_referer": "\/wp\/wp-admin\/admin.php?page=w3tc_general",
    1131,1134c1131,1132
    < "allcache.wp_cron": "0",
    < "pgcache.wp_cron": "0",
    < "minify.wp_cron": "0"
    < }
    ---
    > "allcache.wp_cron": "0"
    > }
    \ No newline at end of file

    Both websites are running W3TC 2.8.13, Gravity Forms reCAPTCHA 2.0.2. The working website is an Elementor website, the other a WPBakery website, but I cannot fathom why one is getting the defer script stripped out?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jamieburchell

    Thank you for reaching out and I am happy to help!

    Can you please go to the Minify advanced settings in Performance>Minify, and under the JS section, check the embed type for Minify Engine settings:

    Let me know if there is a difference in the configuration on those websites when it comes to this option, and let me know if selecting this Embed type helps

    Thanks!

    Thread Starter Jamie Burchell

    (@jamieburchell)

    Hi @vmarko

    Both options on both websites are set to “Default (Blocking)”

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @jamieburchell

    Sorry for the late reply. I was trying to replicate the problem however, I was not able to do so.

    The defer atribute for the minified W3TC scripts is added if the embed type is set to defer. Have you also updated query string once the files were minified?
    Thanks!

    Thread Starter Jamie Burchell

    (@jamieburchell)

    I just disabled all plugins except Gravity Forms, Gravity Forms reCAPTCHA and W3TC. Only enabled minify. Cleared all caches and reset to a default theme.

    Minify enabled:

    <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=X&amp;ver=2.0.2" id="gforms_recaptcha_recaptcha-js" defer="defer" data-wp-strategy="defer"></script>
    <script src="https://example.local.test/app/cache/minify/e2eea.js"></script>

    Minify disabled:

    <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?render=X&amp;ver=2.0.2" id="gforms_recaptcha_recaptcha-js" defer="defer" data-wp-strategy="defer"></script>
    <script type="text/javascript" src="https://example.local.test/app/plugins/gravityformsrecaptcha/js/frontend.min.js?ver=2.0.2" id="gforms_recaptcha_frontend-js" defer="defer" data-wp-strategy="defer"></script>

    I’m stumped as to why it’s getting stripped out.

    Thread Starter Jamie Burchell

    (@jamieburchell)

    Think I found the cause @vmarko

    This regex doesn’t match the string defer="defer". I’ve opened a Github issue.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hey @jamieburchell

    Thank you for submitting the GH issue. the Dev team will take a look at it.
    Pelase make sure you follow the progress of the issue.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.