Hey @seokai,
Unless a form is placed in location that displays globally on your site (such as a footer widget), all WPForms assets and dependencies – including jQuery and reCAPTCHA – are only loaded for pages that contain a form.
Just to triple check this, I spun up a new WordPress install with only the TwentyTwenty theme and WPForms Lite activated. I then created a /contact
page which has WPForms embedded on it.
Viewing the home page and looking at the source, there’s no references to jQuery (https://a.cl.ly/DOuxr7mY) or reCAPTCHA (https://a.cl.ly/WnuJDPq4).
However, once I go to the Contact page which contains a form jQuery (https://a.cl.ly/OAuqje80) and reCAPTCHA (https://a.cl.ly/YEuoW0kb) are indeed included.
I know that it’s common theme and plugin functionality to require jQuery, so my best guess is likely the theme or another plugin that is requiring it globally.
With reCAPTCHA, it’s not as common, but we have seen themes that integrate with reCAPTCHA out of the box load the embed script globally. If you look at the reCAPTCHA script tag, if it doesn’t contain wpformsRecaptchaLoad
(https://a.cl.ly/xQuLx8N0) then that’s a good indicator it’s loading from a call outside WPForms.
Worth nothing, it IS possible to load WPForms assets on every page, but it’s not enabled by default – it’s a nuclear option we provide to users with theme conflicts and similar. Just to be safe, if you go to your WPForms Settings, you’ll see a checkbox for “Load Assets Globally” (https://a.cl.ly/jkuZWN0k).
As far as jQuery as a dependency in general, I do agree that it would be ideal to not need jQuery at all. The thing with that is many of the libraries we use (validation, time picker, payment validation, etc) are jQuery libraries – so finding adequate replacements for these all while attempting to keep backwards compatibility would be a big under taking. That’s not to say it won’t happen, but it will take careful planning and execution.
The other thing is jQuery provides us with a toolkit of helper functions. The library itself is around 34kb gzipped delivered, but refactoring all functionality with vanilla JS and then transpiling could very well negate any gains ditching the dependency itself.
Lastly, we do very much care and pay attention to page load times and general site overhead, because with over 3M sites using WPForms, it’s our duty. We do frequently profile and benchmark releases, so if you see something that looks “off” to you, please let us know so we can investigate.
Anyways, we do really appreciate all feedback. Hope this helps provide some context to things.
Have a great weekend,
Jared