• Resolved digimattia

    (@digimattia)


    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.

    1. 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).
    2. 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):

    1. 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.js
      • wpforms_settings
      • jquery.min.js
      • jquery-migrate.min.js
      • recaptcha/api.js
      • wpforms
      • grecaptcha
      • recaptcha
      • api.js
    2. Page Caching: I have completely disabled page caching for the specific contact page (/kontakt/) via the WP-Optimize settings.
    3. Purging: After every single setting change or added exclusion, I completely purged the WP-Optimize Cache and the Minify cache before re-testing.
    4. Browsers: The issue happens on mobile, web and surely Chrome, Firefox and Edge since I tested with these.

    Despite adding wpforms_settings and the main WPForms JS files to the exclusion list, WP-Optimize still seems to separate the inline script containing wpforms_settings from the main wpforms.min.js file, 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!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks so much for your detailed report! I will run some tests on my test sites with WPForms, Recaptcha v3 and WP-Optimize’s Delay JS feature to see what configuration is needed to get it working properly.

    I’ll keep you updated on my progress!

    I have checked this as well, and maybe this will work

    Paste ALL of these into:

    WP‑Optimize → Minify → JavaScript → Delay JavaScript → Exclusions

    Code

    wpforms_settings
    wpforms-inline
    wpforms
    wpforms-lite
    wpforms-frontend
    wpforms-recaptcha
    wpforms.init
    grecaptcha
    recaptcha
    google.com/recaptcha
    https://www.google.com/recaptcha/api.js
    

    This combination forces WP‑Optimize to:

    • keep the inline settings block in place
    • keep the WPForms frontend script in place
    • keep reCAPTCHA v3 in place
    • delay everything else normally

    This preserves your page speed gains while fixing the form.

    WP‑Optimize → Cache → Page Cache → “Never cache the following pages”

    Add:

    Code

    /kontakt/


    Not sure if it’s a full fix, but hopefully it will work for now till the plugin owners come back.

    • This reply was modified 1 month, 2 weeks ago by fynight.
    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    I’m still testing on my side but so far haven’t managed to get it working, I’ll keep at it!

    @fynight I also tested your solution but I’m still running into the wpforms_settings being undefined error. Had you tested this successfully on your site?

    Thanks all!

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi all,

    So regardless of what I’m adding to the exclusions for Delay JS I wasn’t successful in getting it to work properly.

    After inspecting the HTML for a while, I did notice that the Delay JS feature is changing the inline wpforms_settings script from “type=text/javascript” to “type=text/plain” and upon any mouse movement it changes back to “type=text/javascript”. This is ultimately what’s causing the error about wpforms_settings not being defined, and since it’s an inline script it’s not possible to add an exclusion.

    I was able to come up with a code snippet that intercepts and replaces it back to “text/javascript” and doesn’t require any exclusions added to the Delay JS feature, I just need to do some further validation testing and then I can send it over.

    Thanks!

    This might fix it

    Open your contact page

    Right‑click → Inspect

    Find the inline script containing wpforms_settings

    Look at the script tag — you will see something like:

    <script type=”text/plain” data-wpo-inline-js=”wpforms-inline”> or <script type=”text/plain” data-wp-optimize-inline-js=”wpforms-inline”>

    Add THAT EXACT STRING to the Delay JS exclusions

    Go to:

    WP‑Optimize → Minify → JavaScript → Delay JavaScript → Exclude scripts from Delay

    Add the exact value you found.

    This was based on the plugin author’s help.

    @jbgupdraft I don’t test these fixes people are needing help with online, I run a testing environment and see if I can fix.

    This is my code snippet using PHP and a plugin that allows me to run snippets. You can also add this to functions.php via your child theme. But I have uploaded it to WeTransfer https://we.tl/t-aJyyZBDJfjLYGAKN I would ask the plugin owner to check to see if it will work.

    Which I can not add for some reason lol


    • This reply was modified 1 month, 2 weeks ago by fynight.
    • This reply was modified 1 month, 2 weeks ago by fynight.
    • This reply was modified 1 month, 2 weeks ago by fynight.
    Thread Starter digimattia

    (@digimattia)

    Hey Thanks for all your testing guys.
    I build Websites for other Companies and almost everyone has a Contact Form.

    If I can’t use Recaptcha and WP Optimize in Collaboration, then I loose important features. One gives Speed and the other prevents SPAM submissions.

    I don’t think I am the Only one with this issue. Maybe some didn’t realize it yet.
    If a Solution can be found to solve this inside the Plugin directly that would be best.
    In my Opinion this is a bug. Since Recaptcha is officially from Google, there should be:
    A: an option to allow the whole functionality of the Google Captchas
    B: a way to exclude them from processing

    Since I manage and build multiple Websites and want to do it securely, I would prefer a Fix inside the Plugin and not one I have to add myself. This wouldn’t help the Plugin, wouldn’t help me and also wouldn’t help the Customer.

    It would be very much Appreciated if a good Solution can be developed and shipped through a Plugin Update.

    Thanks again for all you guys help

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    The Javascript snippet is running but unfortunately doesn’t fix the issue I’m still seeing the same error in my console. The snippet that I’m working on uses a regex to find the script and replace the type before its output to the browser.

    @digimattia can you send me a link to any of the pages where you have WPForms forms setup? I want to add some conditionals to my snippet so that it only runs on specific pages.

    Thanks!

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi all,

    I’ve spoken with the developers about this issue and they’re going to investigate and implement better compatibility between WPForms Lite and the Delay JS feature of WP-Optimize. We’ll be able to implement this in a future release and there won’t be any need for any custom code snippets or workarounds.

    Thread Starter digimattia

    (@digimattia)

    Hello and thanks,

    We wanted to ask how the status is of this issue. I saw some new Updates for the Plugin but I didn’t find this addressed in the Release Notes. Is it called differently or is it still beeing investigated?

    Thanks Mattia

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    The newest release doesn’t contain a fix for the issue that development is working on. They’re still investigating and working on a fix for a future release, but I would still recommend updating to the latest version of the plugin!

    Thanks!

    Plugin Support vupdraft

    (@vupdraft)

    I am closing this because there is nothing new to add here. Please keep an eye on our change log for the fix to be released.

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

You must be logged in to reply to this topic.