Serve Responsive Images with Less Page Weight

8 steps · about 3 h 15 min · Intermediate

  1. Understand responsive image problems (guide, MDN Web Docs, 30 min)

    Separate resolution switching from art direction and choose the right HTML mechanism for each.

  2. Use the img element completely (reference, MDN Web Docs, 25 min)

    Review intrinsic dimensions, decoding, loading, fetch priority and accessibility attributes together.

  3. Offer image candidates with srcset (reference, MDN Web Docs, 20 min)

    Let the browser select an appropriate resource by width or pixel-density descriptor.

  4. Describe layout slots with sizes (reference, MDN Web Docs, 20 min)

    Tell the browser how wide an image will render before CSS and the full page have loaded.

  5. Use picture for art direction and formats (reference, MDN Web Docs, 25 min)

    Supply alternate crops or modern formats while retaining a dependable img fallback.

  6. Prioritize the likely largest image (guide, web.dev, 30 min)

    Avoid delaying the image that becomes Largest Contentful Paint through unsuitable loading choices.

  7. Lazy-load only off-screen images (guide, web.dev, 20 min)

    Defer below-the-fold downloads without accidentally delaying prominent content.

  8. Reserve image space to prevent layout shifts (guide, web.dev, 25 min)

    Use intrinsic width and height or aspect ratios so later image decoding does not move surrounding content.