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 5 years, 6 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.

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 3 years, 5 months ago.

Assigned support staff: Christian Cox.


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


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 || [];

Thanks Christian

Yes I think it might be.

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


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.


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 for sharing your solution!


We now have a DOC explaining how to solve issues with optimization plugins, related to Toolset: