Skip Navigation

[Resolved] Uncaught ReferenceError: wptValidationForms is not defined

This thread is resolved. Here is a description of the problem and solution.

Problem: I am seeing a JavaScript error in the console when I try to use Autoptimize and Async JavaScript plugins to speed up my site.

Solution: Remove validation.js from the list of deferred scripts in both plugins

This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 0.96 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 6 replies, has 3 voices.

Last updated by Beda 4 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#520301

I am trying to:
Fix the error:
Uncaught ReferenceError: wptValidationForms is not defined

I visited this URL:
hidden link

I expected to see:
No error

Instead, I got:
The error above

The error started appearing when I started optimizing the speed of my website. The two plugins that seems to be causing it is the following:
Async JavaScript - hidden link
Autoptimize - hidden link

#520311

Hi, it looks like a timing issue where a variable isn't defined yet. Can you try to add the following code to the head of your document:

var wptValidationForms = wptValidationForms || [];
#520328

Thanks Christian

Yes I think it might be.

This is probably a stupid question but where would the best place be to add this?

#520350

Definitely not a stupid question, but I can't say for sure offhand with the implementation of these async, caching and optimization plugins. It all depends on how your site's code is architected, when dependencies like jQuery are loaded, the order in which things are initialized, etc. I would try adding it in Layouts CSS and JS first, to prevent the need to enqueue another script file. If that doesn't resolve the unregistered error consistently across the site, I can investigate further.

#520558

Hi Christian

Thanks for the feedback. I managed to resolve the issue by excluding the validation.js script from the scripts to be deferred. There is an option for that on both plugins.

Thanks
Leonard

#521142

Thanks for sharing your solution!

#1269107

We now have a DOC explaining how to solve issues with optimization plugins, related to Toolset:
https://toolset.com/faq/how-to-use-optimization-plugins-with-toolset/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.