Responsive Modern Image Delivery
Images typically account for the largest share of page transfer bytes. Combine modern codecs (AVIF and WebP) with responsive srcset and sizes attributes so mobile devices never download desktop-width assets:
<picture>
<source
type="image/avif"
srcset="/assets/images/diagram-640.avif 640w, /assets/images/diagram-1280.avif 1280w"
sizes="(max-width: 768px) 100vw, 760px">
<source
type="image/webp"
srcset="/assets/images/diagram-640.webp 640w, /assets/images/diagram-1280.webp 1280w"
sizes="(max-width: 768px) 100vw, 760px">
<img
src="/assets/images/diagram-1280.jpg"
width="1280"
height="720"
loading="lazy"
decoding="async"
alt="Network request waterfall comparison">
</picture>
Image Loading Rules
- Above the Fold (LCP): Omit
loading="lazy"and addfetchpriority="high". - Below the Fold: Add
loading="lazy"anddecoding="async"so off-screen images do not compete with critical assets for bandwidth or main-thread decode time. - Always Set
widthandheight: Prevents Cumulative Layout Shift during progressive loading.
Webfont Optimization Checklist
- Use WOFF2 Exclusively: WOFF2 provides ~30% better compression than WOFF and is universally supported across modern browsers.
- Subset by
unicode-range: Split Latin, extended diacritics, and symbol ranges so English pages do not download unused glyph tables. - Prefer Variable Fonts Over Multiple Static Weights: A single
InterVariable.woff2file covering weights400–700is often smaller than loading three separate static font files and avoids extra HTTP requests. - Set
font-display: swap(oroptional): Ensures text renders immediately in a fallback system font rather than remaining invisible during slow connections.