formie icon indicating copy to clipboard operation
formie copied to clipboard

Load recaptcha when user interacts with form

Open danfathom opened this issue 2 years ago • 10 comments

What are you trying to do?

It would be great if there was option in Formie to only load recaptcha once the user interacts with a form. Google lighthouse always shows loading Google recaptcha as something that slows down the page load (mainly on mobile) due to the JS file being around 150kb.

This is a feature on Freeform and would be great to have the ability to do this on Formie too.

What's your proposed solution?

Add a script, to only load the google recaptcha JS file once the user interacts with the first required field on a form.

Additional context

No response

danfathom avatar Oct 12 '22 10:10 danfathom

Sounds like a good idea, thanks!

engram-design avatar Oct 12 '22 11:10 engram-design

Hi, I don't suppose you have any plans to implement this feature in the near future? :)

danfathom avatar Dec 14 '22 09:12 danfathom

We certainly do, yes, but no ETA. Likely in 2.1 early next year.

engram-design avatar Dec 14 '22 09:12 engram-design

Ok sounds great, thanks!

danfathom avatar Dec 14 '22 09:12 danfathom

Chipping in my desire for this too :) Having the recaptcha thing show up on every page of the site is annoying.

darylknight avatar Nov 10 '23 10:11 darylknight

Hi,

Just re-visiting this - is there any plan to include this feature in the near future? We use google re-captcha on our sites, and it's size is 385.5KiB, which is negatively impacting our google lighthouse page speeds.

Thanks

danfathom avatar Jan 30 '24 10:01 danfathom

It's 100% on our radar, and will be implemented in Formie 3 for Craft 5. In fact, this is already available in the craft-5 branch. We'll look to back-port this to Craft 4 if there's demand for this but it will be after our Craft 5 work.

In addition, Formie 3 will also not initialize its JS until the form is visible, bringing even further improvements.

engram-design avatar Jan 30 '24 10:01 engram-design

That second part will be super awesome. We have a site that has a contact form in the footer of every page, so not initialising the JS until you scroll down will be a big deal :)

darylknight avatar Jan 30 '24 10:01 darylknight

@engram-design hey Josh, I second that. Are there any updates on back-porting to Craft 4 yet? We have a quote form on every page, Lighthouse reports Captcha is the biggest culprit

hassanmah avatar Apr 13 '24 22:04 hassanmah

I’m hesitant to backport it as-is without it being a breaking change, so might have to enable the behaviors behind a flag.

I’ll look into it.

engram-design avatar Apr 13 '24 23:04 engram-design