Are your CaptainForms not working, or are you seeing "Uncaught ReferenceError: captainform_preload_form_popup is not defined" in your website's console? This error can disrupt the functionality of your site's features, such as accordions or tabs that suddenly refuse to work. Fortunately, this issue is resolvable, most commonly associated with conflicts arising from script deferral in caching and optimization plugins like WP Rocket.
Resolve the "Uncaught ReferenceError: captainform_preload_form_popup" error by:
- Temporarily disabling WP Rocket to check if errors stop.
- If resolved, exclude 'captainform-form-popup.js' from WP Rocket's script deferral.
- Clear cache and verify if site features work without error.
Understanding the Error
WP Rocket Configuration
Troubleshoot with WP Rocket Disabled:
Temporarily disable WP Rocket on your website. By doing so, you check if script deferral is the cause of the issue. If the error vanishes and the Captain Forms on your site start work correctly, you've found the culprit.
Exclude Scripts from Deferral:
Rather than keeping WP Rocket disabled (which could impact your site's performance), you can tell WP Rocket to exclude the CaptainForm script from being deferred. To do this, you'll need to:
- Access WP Rocket's settings in your WordPress admin panel.
- Navigate to the File Optimization tab.
captainform-form-popup.js– to the exclusion list.
Verify the Results:
After making these changes, clear your site’s cache and browser cache. Then verify that the site is functioning correctly with no errors in the console.
Script deferral is a powerful speed optimization, but occasionally, it may need tweaking to play nicely with all your plugins. By following these steps, you'll be able to enjoy both the speed advantages of WP Rocket and the full functionality of the CaptainForm plugin.