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

WordPress Trac noreply at wordpress.org
Wed Dec 11 10:29:24 UTC 2019


#44427: Introduce lazy-loading API for media and other elements
--------------------------------------+--------------------------
 Reporter:  mor10                     |       Owner:  flixos90
     Type:  feature request           |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.4
Component:  Media                     |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------

Comment (by flixos90):

 [attachment:"44427.7.diff"] is based on [attachment:"44427.5.diff"]:

 * It limits default support status to `img` tags only and modifying the
 filter so that it can be used to whitelist specific tags to be supported
 (e.g. to also include `iframe` tags). I think only supporting `img` tags
 initially by default is a safer bet, and also way more important because
 of how much they're used - we can revisit `iframe` support in the future,
 for now it's possible via filter.
 * It consolidates this logic into a function `wp_get_lazy_load_tags()` so
 that the filter does not need to be called in multiple locations.
 * It includes more solid logic to add `loading="lazy"` attributes to
 content strings, based on @westonruter's feedback in
 https://github.com/WordPress/wordpress-develop/pull/123.
 * For specific image functions, the attribute is added in these functions
 because running the catch-all `wp_lazy_load_content_media()` function
 would be overly expensive for such a case where we know the string is just
 a single tag.

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


More information about the wp-trac mailing list