josiasmontag / laravel-recaptchav3

Laravel package for Google's Recaptcha V3
MIT License
188 stars 37 forks source link

Defer the loading recaptcha__en.js #39

Open iWpress opened 4 months ago

iWpress commented 4 months ago

Hello, I really like this package. I had no problems setting it up and using it. But lately, the download of the recaptcha__en.js script from www.gstatic.com is the slowest resource that affects my site speed the most. Is it possible to defer the loading of this script? Best Regards.

iWpress commented 4 months ago

Until the page is loaded and the user fills out the form, reCAPTCHA is not needed at all. This is exactly the situation when you need to defer loading.

The problem is that when you make changes to the initJs() method on: return '<script async src= or return '<script defer src= I get a notification: required: Please verify that you are not a robot

Although this is exactly what is recommended in Google's documentation: https://developers.google.com/recaptcha/docs/loading

@josiasmontag tell me, please, in which direction to look.

iWpress commented 4 months ago

I started a discussion on the forum. So far, there is no good solution.