Add intersection observer to lazyload Oembed iframes

Created on 1 December 2023, over 1 year ago
Updated 8 January 2024, over 1 year ago

Problem/Motivation

The loading="lazy" attribute on iframes may not consistently deliver the desired results. Despite enabling loading="lazy" for all embed iframes, page speed scores often remain suboptimal.

Steps to reproduce

Add loading lazy to any oembed iframe like youtube. Conduct a Google lighthouse page speed assessment and observe an increase in unused JavaScript, impacting the overall page speed score.

Proposed resolution

To address this, a more effective solution involves implementing a native JavaScript Intersection Observer to lazy-load iframes.

Lighthouse scores before with loading lazy:

Lighthouse scores with intersection observer:

Notice in the loading lazy screenshot there is a "Reduce unused JavaScript".
That coming from all the extra JS from the iframe like youtube.

✨ Feature request
Status

Needs work

Version

10.2 ✨

Component
MediaΒ  β†’

Last updated 29 minutes ago

Created by

πŸ‡ΊπŸ‡ΈUnited States andysipple

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024