-
Notifications
You must be signed in to change notification settings - Fork 145
Image Prioritizer fails to preload LCP images for picture elements #1312
Copy link
Copy link
Labels
[Plugin] Image PrioritizerIssues for the Image Prioritizer plugin (dependent on Optimization Detective)Issues for the Image Prioritizer plugin (dependent on Optimization Detective)[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)Issues for the Modern Image Formats plugin (formerly WebP Uploads)[Plugin] Optimization DetectiveIssues for the Optimization Detective pluginIssues for the Optimization Detective plugin[Type] BugAn existing feature is brokenAn existing feature is broken
Metadata
Metadata
Assignees
Labels
[Plugin] Image PrioritizerIssues for the Image Prioritizer plugin (dependent on Optimization Detective)Issues for the Image Prioritizer plugin (dependent on Optimization Detective)[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)Issues for the Modern Image Formats plugin (formerly WebP Uploads)[Plugin] Optimization DetectiveIssues for the Optimization Detective pluginIssues for the Optimization Detective plugin[Type] BugAn existing feature is brokenAn existing feature is broken
Type
Fields
Give feedbackNo fields configured for Bug.
Projects
Status
Done 😃
The Image Prioritizer plugin adds a preload
linktag withfetchpriority=highfor the URL contained in thesrcattribute of theimg. When the Modern Image Formats plugin is active and the "Use<picture>element" option is enabled, then theimgis wrapped inpicturewith othersourceelements for WebP and AVIF image formats. Because of this, the preload link will usually be wrong because the actual URL being used for the LCP image will be the WebP or AVIF image, not the JPEG fallback.For example, a page containing this LCP element:
Is getting this preload link:
In this specific example, the LCP element is the same across all breakpoints, so the
fetchpriority=highon theimgitself is sufficient and the preload link is not required. Nevertheless, if the LCP element is not the same across all breakpoints, thefetchpriority=highattribute cannot be added to theimgor else it will get loaded with high priority for some breakpoints for which it is not the LCP image. This basically uncovers a performance problem with using<picture>as it cannot be reliably loaded with high priority to improve LCP. This is essentially a known issue per GoogleChrome/web.dev#6150.For Image Prioritizer, the preload link needs to be omitted when the related LCP element is a
pictureelement. It can still addfetchpriority=highto theimgas it does now when all breakpoints share it as the LCP element.Cheers to @aaemnnosttv for talking this through with me at WCEU.