Load JS Deferred (Delayed) and broken scripts like CF7




Wordpress LScache Plugin: Load JS Deferred (Delayed) and broken scripts like CF7

Last Updated on: Wed, 15 Apr 2026 00:00:02
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.js I 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) Hi, unfortunately thats the only option we have so far to deal such kind of issue Best regards, Hi @CacheCrawler, thank you for your answer. I wonder how the nitropack.io plugin is dealing with this problem. Here is example (cf7 + Load JS Deferred): https://ckadn.pl/kontakt/ When I type on the dev console: getEventListeners(document) ?I see: ? DOMContentLoaded ? DOMContentLoadedNitro



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference