Skip to content

Defer offscreen images recommendation for reCAPTCHA logo #580

@sntgchns

Description

@sntgchns

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.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions