Modern image & webfont optimization

Cutting payload size by 50–80% with responsive AVIF/WebP image pipelines and fast, layout-stable WOFF2 typography.

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 add fetchpriority="high".
  • Below the Fold: Add loading="lazy" and decoding="async" so off-screen images do not compete with critical assets for bandwidth or main-thread decode time.
  • Always Set width and height: Prevents Cumulative Layout Shift during progressive loading.

Webfont Optimization Checklist

  1. Use WOFF2 Exclusively: WOFF2 provides ~30% better compression than WOFF and is universally supported across modern browsers.
  2. Subset by unicode-range: Split Latin, extended diacritics, and symbol ranges so English pages do not download unused glyph tables.
  3. Prefer Variable Fonts Over Multiple Static Weights: A single InterVariable.woff2 file covering weights 400–700 is often smaller than loading three separate static font files and avoids extra HTTP requests.
  4. Set font-display: swap (or optional): Ensures text renders immediately in a fallback system font rather than remaining invisible during slow connections.