Delay JS breaks WPForms & reCAPTCHA v3
-
Hi WP-Optimize Team,
I am experiencing a critical issue where enabling the “Delay JS” feature breaks my WPForms submission due to JavaScript execution order, specifically concerning Google reCAPTCHA v3.
If I disable “Delay JS”, the form works perfectly.
Here are the detailed specifications of the issue and my environment:
Environment:
- Plugins: WPForms Lite (latest), WP-Optimize Free (latest)
- WordPress Version: 6.9.4
- PHP Version: 8.3.29
- Active Theme: Astra 4.12.7
- Spam Protection: Google reCAPTCHA v3 configured within WPForms.
The Problem: When Delay JS is active, users cannot submit the form.
- Frontend Error: After clicking submit, the form shows the error: “Google-reCAPTCHA-Prüfung gescheitert, bitte später erneut versuchen.” (Google reCAPTCHA verification failed, please try again later).
- Console Errors: The console shows that WPForms fails to initialize because its settings object is missing before the main script fires:
JQMIGRATE: Migrate is installed, version 3.4.1 jquery.min.js?ver=3.7.1:2 jQuery.Deferred exception: wpforms_settings is not defined ReferenceError: wpforms_settings is not defined at HTMLFormElement.<anonymous> (wpforms.min.js?ver=1.10.0.4:1:1330) at ce.each (jquery.min.js?ver=3.7.1:2:3129) at Object.loadHoneypot (wpforms.min.js?ver=1.10.0.4:1:1259) at HTMLDocument.ready (wpforms.min.js?ver=1.10.0.4:1:377)Uncaught ReferenceError: wpforms_settings is not defined
Troubleshooting steps I have already taken (without success):
- Exclusions: I tried excluding all relevant files and keywords in both the general JS exclusion settings and the specific Delay JS exclusion box. I tried adding the following terms:
/wp-content/plugins/wpforms-lite//wp-content/plugins/wpforms-lite/assets/js/frontend/wpforms.min.jswpforms_settingsjquery.min.jsjquery-migrate.min.jsrecaptcha/api.jswpformsgrecaptcharecaptchaapi.js
- Page Caching: I have completely disabled page caching for the specific contact page (
/kontakt/) via the WP-Optimize settings. - Purging: After every single setting change or added exclusion, I completely purged the WP-Optimize Cache and the Minify cache before re-testing.
- Browsers: The issue happens on mobile, web and surely Chrome, Firefox and Edge since I tested with these.
Despite adding
wpforms_settingsand the main WPForms JS files to the exclusion list, WP-Optimize still seems to separate the inline script containingwpforms_settingsfrom the mainwpforms.min.jsfile, causing the ReferenceError and breaking the reCAPTCHA token generation. The delay helps in page speed and I want to keep it active, if it breaks the functionality to submit the contact form it makes it hard for us. Also If an Exclusion is needed, to maintain page speed for the rest of the pages, it would be optimal to only exclude the things that hurt this functionality and not anything else.Is there a specific regex or exact string or whatever option I need to use to properly exclude WPForms and reCAPTCHA v3 from the Delay JS feature? Any help would be greatly appreciated.
Thank you in advance!
You must be logged in to reply to this topic.