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 #44427 (Introduce lazy-loading API for media and other elements) ā€“ WordPress Trac 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: Issues Ā· ClassicPress/ClassicPress Ā· GitHub

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.