[wp-trac] [WordPress Trac] #53232: Add async decoding attribute as default to the HTML image tags generated by WordPress

WordPress Trac noreply at wordpress.org
Fri May 21 08:09:43 UTC 2021


#53232: Add async decoding attribute as default to the HTML image tags generated by
WordPress
-----------------------------+------------------------------
 Reporter:  isaumya          |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Media            |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:  performance
-----------------------------+------------------------------

Comment (by ayeshrajans):

 This will be a nice one, thank you for opening the ticket.

 I took a quick look at how lazy loading is currently implemented, and I
 think we should follow suit:

  - Add `wp_img_tag_add_decoding_attr` filter akin
 `wp_img_tag_add_loading_attr` to determine offer attribute value.
  - Add `wp_img_tag_add_decoding_attr` function akin
 `wp_img_tag_add_loading_attr` to make the actual change.
  - Update `wp_filter_content_tags` to call `wp_img_tag_add_decoding_attr`.
  - Make sure kses allow-lists the `decoding` attribute.
  - Add test coverage.

 I would suggest to only add the `decoding` attribute only if
 `loading=lazy` is also present. This ''might''(?) reduce sudden content
 reflows.

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


More information about the wp-trac mailing list