-
Notifications
You must be signed in to change notification settings - Fork 776
Description
The reCAPTCHA logo (https://www.gstatic.com/recaptcha/api2/logo_48.png) is being flagged by PageSpeed Insights with a "Defer offscreen images" recommendation.
Our site is already implementing lazy-loading for the reCAPTCHA script, so it only loads dynamically when a user activates the form. However, once the script is loaded, the reCAPTCHA logo image is still loaded eagerly, which triggers this performance recommendation.
Since the image is rendered and controlled by the reCAPTCHA script, it's not possible for us to add the loading="lazy" attribute directly to the image tag.
We are lazy-loading the reCAPTCHA script using the following method: a JavaScript function creates a <script> element and appends it to the DOM on a user-initiated event (e.g., a click on a checkbox). This ensures the script is not loaded until it's needed.
We would like to request that the reCAPTCHA service implements lazy loading for the logo image itself to further improve web performance for sites that use the service.
The current potential savings are small (2.2 KiB), but this change would help sites achieve better performance scores and reduce the time to interactivity, especially on pages where the reCAPTCHA widget is not immediately visible.
