Perfformance: Lazy-load editor images#212
Merged
Merged
Conversation
Add loading="lazy" and decoding="async" to the three off-screen images we render in the shell: the document cover, the page icon, and the featured image preview in the inspector. None of these are above the fold in their typical context, so deferring fetch and decoding shaves work off the initial render without changing layout.
Performance vs mainWorkload changed in 2 scenarios. 6 scenarios with notable timing changes.
Full numbers in the job summary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add
loading="lazy"anddecoding="async"to three<img>tags in the editor shell:document-coverblockPageIcon(sidebar and command palette)PageInspectorSidebarWhy
None of these are on screen at first render, so the browser doesn't need to fetch or decode them eagerly.
decoding="async"also lets the decode work happen off the main thread.WordPress core sets the same attributes on the public frontend via
wp_get_attachment_image(). This brings the editor's own<img>tags in line.Test plan