[wp-trac] [WordPress Trac] #44427: Introduce lazy-loading API for media and other elements

WordPress Trac noreply at wordpress.org
Wed Aug 28 10:35:07 UTC 2019


#44427: Introduce lazy-loading API for media and other elements
----------------------------------------+------------------------------
 Reporter:  mor10                       |       Owner:  (none)
     Type:  feature request             |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Media                       |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  needs-unit-tests has-patch  |     Focuses:  performance
----------------------------------------+------------------------------

Comment (by flixos90):

 I think the patch by @spacedmonkey is a good first step in the right
 direction.

 @jonoaldersonwp
 > I've never seen an exclusion-based approach.
 > [...]
 > Trust those two to have frustrating anti-patterns.

 I think for the WordPress ecosystem a blacklist approach is more
 beneficial than an whitelist approach. If we relied on whitelisting images
 to lazy-load, we would probably never get to a wide adoption, because most
 users wouldn't know about the possibility entirely. With blacklisting, we
 lazy-load as much as possible by default, and if someone wants to exclude
 certain media from that, they can do so without negatively affecting the
 adoption of lazy-loading in WordPress. From my observations, I'd agree
 that one of the most common exclusion mechanisms appears to be a class
 `skip-lazy`. We should decide on what mechanism we'd want to support for
 exclusion for a core implementation.

 I'd also like to confirm @addyosmani's point about interoperability: Sites
 that currently use a JavaScript-based approach for lazy-loading won't be
 affected, as for these solutions there most likely won't be a `src`
 attribute on the images.

 I have one major concern about the currently proposed route for core,
 which is relying on theme support. Lazy-loading images is a general site
 feature that ties in with any functionality on the site and is not
 specific to themes. Furthermore, requiring theme support would leave the
 feature largely unused, since basically every theme in the world would
 need to be updated to `add_theme_support( 'lazy-loading-images' )` first.
 If we want to easily allow enabling/disabling lazy-loading, I'd much
 rather prefer a user-centric, sitewide approach. That could either be an
 option to enable/disable it (e.g. a core-shipped Customizer control), or a
 filter.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44427#comment:39>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list