Defer attribute on scripts being removed?
-
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&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&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&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
e2eeascript 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&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 fileBoth 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?
You must be logged in to reply to this topic.
