0

I'm exploring ways to improve our Google Pagespeed score and, ironically, I've found that the biggest negative impact on our score is from Google reCAPTCHA. I'm using the default Magento 2.3.0 reCAPTCHA implementation but I've found that this loads the reCAPTCHA js and css on EVERY page - not just pages with forms where protection is needed. Is this the expected behaviour (or do I have a bug) and is there some way to configure Google reCAPTCHA to only load for the specified forms?

I'm using invisible reCAPTCA version 3.

Is this issue resolved in later Magento versions ?(i.e. 2.4.*) I'm already considering an upgrade for other reasons.

Thanks for any help...

1

Without knowing the specific files that are flagged by PageSpeed, I can't say for sure whether the following addresses your question.

In 2.4.x, if reCAPTCHA is configured for customer login, reCAPTCHA elements are required on every page to facilitate the authentication popup that is displayed when guests click the "Proceed to Checkout" button from the mini-cart (though this may depend on checkout configurations). This behavior is configured in vendor/magento/module-re-captcha-customer/view/frontend/layout/default.xml.

In 2.3.x (which I can't check directly) vendor/msp/recaptcha/view/frontend/layout/default.xml indicates that reCAPTCHA elements will load on every for the same reason or if it is enabled for newsletter signups.

2
  • Thank you for the info, although not the best news. Does this mean that every Magento 2 store is at a disadvantage because of the reCAPTCHA code? It seems like we're stuck with this issue - unless we disable reCAPTCHA - which is unthinkable nowadays... – Sparko Jun 6 at 19:07
  • This suggests that any Magento 2 site using the default reCAPTCHA implementation would be similarly dinged by PageSpeed. It is probably possible to customize your site to avoid it, e.g. by removing the option to go from the mini-cart directly to checkout, or by sending them to the login page and automatically redirecting them to checkout: magento.stackexchange.com/questions/337887/…. If the authentication-popup isn't used, the configuration can be removed from default.xml. – jiheison Jun 6 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.