Image Prioritizer
This plugin optimizes the loading of images (and videos) with prioritization to improve Largest Contentful Paint (LCP), lazy loading, and more accurate image size selection. The current optimizations include: Add breakpoint-specific fetchpriority=high preload links (both as LINK[rel=preload] element
About this tool.
This plugin optimizes the loading of images (and videos) with prioritization to improve Largest Contentful Paint (LCP), lazy loading, and more accurate image size selection.
The current optimizations include:
- 01Add breakpoint-specific fetchpriority=high preload links (both as LINK[rel=preload] elements and Link response headers) for image URLs of LCP elements: An IMG element, including the srcset / sizes attributes supplied as imagesrcset / imagesizes on the LINK .
- 02The first SOURCE element with a type attribute in a PICTURE element. (Art-directed PICTURE elements using media queries are not supported.)
- 03An element with a CSS background-image inline style attribute.
- 04An element with a CSS background-image applied with a stylesheet (when the image is from an allowed origin).
- 05A VIDEO element’s poster image.
Ensure fetchpriority=high is only added to an IMG when it is the LCP element across all responsive breakpoints. Add fetchpriority=low to IMG tags which appear in the initial viewport but are not visible, such as when they are subsequent carousel slides. Lazy loading:
- 06Apply lazy loading to IMG tags based on whether they appear in any breakpoint’s initial viewport.
- 07Implement lazy loading of CSS background images added via inline style attributes.
- 08Lazy-load VIDEO tags by setting the appropriate attributes based on whether they appear in the initial viewport. If a VIDEO is the LCP element, it gets preload=auto ; if it is in an initial viewport, the preload=metadata default is left; if it is not in an initial viewport, it gets preload=none . Lazy-loaded videos also get initial preload , autoplay , and poster attributes restored when the VIDEO is going to enter the viewport.
Responsive image sizes:
- 09Ensure sizes=auto is set on IMG tags after setting correct lazy-loading (above).
- 10~~Compute the sizes attribute using the widths of an image collected from URL Metrics for each breakpoint (when not lazy-loaded since then handled by sizes=auto ).~~ (This has been removed due to an issue ; use Enhanced Responsive Images instead .)
Reduce the size of the poster image of a VIDEO from full size to the size appropriate for the maximum width of the video (on desktop).