Add Lazy loading by default to CP Core

Borrowing the description;

In Chrome 76, you can use the loading attribute to completely defer the loading of offscreen images and iframes that can be reached by scrolling:

…

Here are the supported values for the loading attribute:

> auto: Default lazy-loading behavior of the browser, which is the same as not including the attribute.
> lazy: Defer loading of the resource until it reaches a calculated distance from the viewport.
> eager: Load the resource immediately, regardless of where it's located on the page.

Morten in https://core.trac.wordpress.org/ticket/44427 makes a good case for this. Can we work on this since it does not make any breaking changes? It is an enhancement that I see since I come from a location where we have bad bandwidth and network.

See lazy loading in effect here: https://web.dev/native-lazy-loading/lazyload.webm


Read-only archive: GitHub Ā· Where software is built

Author: Laurence Bahiirwa

Vote count: 18

Status: Completed (v1.5.0)


Comments

Lazy loading was added to WordPress. Should we consider backporting this feature?

1 Like

Yes, it’s one thing I miss from WP… This gets my vote.

It’s now more-or-less a web standard: "loading" | Can I use... Support tables for HTML5, CSS3, etc

But there’s quite a few changesets involved. Just recording them here for future reference:

  • 47554
  • 48170
  • 48237
  • 48272
  • 48648
  • 48649
2 Likes

From what I could tell in the support forums, the original lazy load worked, but the attribute was added to all images. They fixed it so it wasn’t added to the header image.
In a later release, they added it to iframes. This caused problems, and I’m not sure that is all fixed.
I would put it only on images.

1 Like

There is a PR for this on GitHub:

1 Like

This was introduced in v1.5.0. It will be included in the re-fork for v2.