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

WordPress Trac noreply at wordpress.org
Sat Jan 11 00:40:00 UTC 2020


#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 2nd-        |     Focuses:
  opinion                                        |  performance
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Some initial thoughts when looking at 44427.8.diff:

 - Leave auto-adding of `loading="lazy"` to iframes out for now. Looking at
 the specs, there's no mention of iframes anywhere (unless I'm missing
 something): https://github.com/whatwg/html/pull/3752/files. The specs are
 not finalized yet, thinking we can add support for iframes when/if it
 becomes official. Another reason is that iframes are rarely used in user
 supplied content. The most common use is in markup from oEmbed. Seems
 better to not modify it, at least for now.

 - Instead of adding `preg_replace_callback()` for img tags, abstract and
 reuse (or replace) the existing `preg_match_all( '/<img [^>]+>/',
 $content, $matches )` in `wp_make_content_images_responsive()`. Ideally
 this should also pass some context, perhaps `current_filter()`, but also
 may support some sort of a `$context` param.

 - I'm not particularly fond of `wp_get_lazy_load_tags()`, especially if
 we're not supporting iframes for now, but it makes sense to have a helper
 function that "holds" a filter to globally enable/disable auto-adding of
 the `loading` attribute. (May need more thinking/reviews).

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


More information about the wp-trac mailing list