all modern browsers • AVIF image decode support landing in Chrome & Firefox • JPEGXL decoding behind a fl ag in Chrome • Lazy-loading images in Chrome, FF, Safari TP. A default in WordPress • Compute img/video aspect ratio from width/height attributes • FF support for preload, Chrome: imagesrcset and imagesizes on link rel=preload • width/height on <source> elements for <picture> • and more! 2020-2021
to get the sense of a visual scene 0.01s How much we recall of what we see or do vs. 20% of what we read. 80% Increase in willingness to read due to color visuals. 80% Neuroscience How much audiences more likely to be persuaded by a talk with visuals vs. a purely verbal one 17% To process a symbol and 100ms to attach meaning to it. 150ms Sources: goo.gle/imgsci
Largest Contentful Paint • Request your key hero image early • Use <picture>, srcset + e ff i cient modern image formats • Avoid wasting pixels (compress, don't serve overly high DPR images) • Lazy-load o ff screen images (reduce network contention for key resources) • For a low Cumulative Layout Shift • Set dimensions (width, height) on your images • Use CSS aspect-ratio or aspect-ratio boxes to reserve space otherwise • For a low impact First Input Delay • Avoid images causing network contention with other critical resources like CSS and JS.
lastEntry = entries[entries.length - 1]; return lastEntry.element; } LCP API (RUM) web.dev/debug-web-vitals-in-the- fi eld/ User devices have di ff erent screen resolutions, which results in di ff erent page layouts and thus di ff erent elements being visible within the viewport. Content may be personalized for the current user, so the LCP candidate element could vary wildly from user to user. 🔬 ⛰
factors determine the best image size • Screen size and resolution • Viewport • Layout and responsive breakpoints • Device pixel ratio (physical resolution) • Art direction Can one size fi t all?
sizing to prevent layout shift • Automatic lazy-loading of o ff screen assets • Framework-speci fi c asset prioritization optimizations • Flexible layout options • Customizable loader support for any image server or CDN Features and bene fi ts Up to 60% faster LCP and up to 100% reduced CLS
srcsets for images • Enforced sizing to prevent layout shift • Automatic lazy-loading of o ff screen assets • Framework-speci fi c asset prioritization optimizations • Flexible layout options • Customizable loader support for any image server or CDN Up to 60% faster LCP and up to 100% reduced CLS
improve LCP included resizing their hero image, optimizing SVGs and using media queries to limit loading o ff screen images. Their optimizations to LCP included a 2.5s saving from switching their fi rst large image from being behind JavaScript (client-side hydration) to being directly in the main HTML document. 70% improvement in LCP correlated with a 76% reduction in load abandonment They determined shifts were caused after their hero images were loaded and snapped in for the fi rst view. They used Aspect Ratio Boxes to reserve space before their image was loaded. Optimizations to CLS helped increase News page views per session by 15% French Fashion house Chloè used Link Preload to preload their 1x and 2x Hero images, which were previously bottlenecked by a render-blocking script. Preloading 1x and 2x Hero images bottlenecked by render- blocking script improved LCP by 500ms (based on CrUX)
components that build on <img>, like Next.js <Image> (for React) and Nuxt image (for Vue) try to bake in as many of these concepts as possible by default. • You can of course also do this manually just using the <img> element directly. • If using 11ty for your static sites, try the 11ty high-performance blog template.
the one driving image loading so <picture> and srcset fall off of that --> <picture> <source media="(min-width: 40em)" srcset="big.jpg 1x, big-hd.jpg 2x"> <source srcset="small.jpg 1x, small-hd.jpg 2x"> <img src="fallback.jpg" loading="lazy"> </picture>
Largest Contentful Paint • Request your key hero image early • Use srcset + e ffi cient modern image formats • Avoid wasting pixels (compress, don't serve overly high DPR images) • Lazy-load o ff screen images (reduce network contention for key resources) • For a low Cumulative Layout Shift • Set dimensions (width, height) on your images • Use CSS aspect-ratio or aspect-ratio boxes to reserve space otherwise • For a low impact First Input Delay • Avoid images causing network contention with other critical resources like CSS and JS.