Load JS Deferred (Delayed) and broken scripts like CF7
-
I am using Contact Form 7 forms on the website and they stopped working when I turned the option:
Page Optimization -> Load JS Deferred -> Delayed
When I submit the form, the page reloads instead of making the request in the background (ajax). Most likely, this is because the cf7 script (https://github.com/takayukister/contact-form-7/blob/master/includes/js/index.js) configures forms in response to an DOMContentLoaded event.I know I can exclude cf7 scripts (Tuning -> JS Deferred Excludes):
wpcf7 (variable definition inline script)
/contact-form-7/includes/js/index.jsI wonder if there is some way to deal with the scripts that listen to DOMContentLoaded event. I could manually trigger an event in a script that is loaded at the very end:
window.document.dispatchEvent(new Event(“DOMContentLoaded”, {
bubbles: true,
cancelable: true
}));…but I am concerned about how scripts that are excluded from delayed loading and are also based on this event will behave (double triggering DOMContentLoaded event)
- The topic ‘Load JS Deferred (Delayed) and broken scripts like CF7’ is closed to new replies.