Skip to content

Add decoding=async attribute to images by default#1853

Closed
westonruter wants to merge 1 commit intoWordPress:trunkfrom
westonruter:add/img-decoding-async-attr
Closed

Add decoding=async attribute to images by default#1853
westonruter wants to merge 1 commit intoWordPress:trunkfrom
westonruter:add/img-decoding-async-attr

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Nov 9, 2021

Note that most of the test changes are to make testing work on more environments, specifically where the wp-content directory is not in the standard location.

Trac ticket: https://core.trac.wordpress.org/ticket/53232


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

}
}

$attr['decoding'] = 'async';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the question will be whether this should have a filter like lazy-loading does via wp_lazy_loading_enabled(). Should there be a wp_async_decoding_enabled() function and filter passed the same args?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In contrast with lazy-loading in which lazy is omitted for images likely to be in the first viewport, the decoding=async attribute would still be added to all images.

@mehigh
Copy link

mehigh commented Feb 25, 2022

Have done the tests and covered the potential caveats I could think about, and this is passing with flying colors, as the lab+local tests have contradicted some of the conclusions I've drawn after reading the specifications.

Full result of the research posted on Trac :
https://core.trac.wordpress.org/ticket/53232#comment:34

TL;DR:
Explored several edge-cases in order to find potential downsides from including this attribute. Used webpagetest, GPSI & local lighthouse tests for all tests to confirm conclusions. Used performance profiling to go deeper and confirm the data/conclusions when the results were too consistent in the lab tests.
A big thumbs-up for this to be the default option for all images, not just the ones in the_content.

@westonruter
Copy link
Member Author

Closing in favor of #2409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants