Web Design

Stop shipping your 3000px hero to phones

Our blog heroes ship at 2976 pixels wide because that is the size the generator produces and the size a desktop hero wants. A phone with a 390-pixel viewport receives the same 600-plus-kilobyte file and downscales it to invisibility. The fix costs four HTML attributes, no rebuild of the pipeline, and no JavaScript. Here is the set, in the order that matters.

srcset and sizes: the width contract

The srcset attribute lists the resolutions an image exists in. The sizes attribute tells the browser how wide the slot will be at each viewport width. The browser knows its own screen density and picks the smallest file that fills the slot cleanly. The designer generates two or three sizes once; the negotiation happens on the device, per visitor, forever.

Two rules keep it honest. Generate sizes at fixed multiples, 800, 1600, and 2976 in our case, so the list stays readable. And write sizes to match the rendered layout, not the screen: a hero that spans half a laptop window needs a sizes entry for laptops that says half, not full. Mismatched sizes attributes make browsers over-download, which quietly erases the savings.

loading and fetchpriority: the order contract

Lazy loading tells the browser to skip images below the fold until the reader scrolls near them. One attribute, no JavaScript, and every below-fold image on a long page stops competing for bandwidth. The native loading attribute is supported across current browsers, as Google's browser-level lazy loading page documents, which retired the old JavaScript intersection-observer snippets for most sites.

The hero needs the opposite instruction. Lazy-loading the largest above-fold image delays the main paint and tanks the score, so the hero gets loading eager and fetchpriority high, which tells the browser to fetch it before the scripts and styles queue up. One image per page earns the high priority. Marking several defeats the ordering the attribute exists to provide.

The fallback habit

Modern formats come with a fallback chain wrapped in the picture element: WebP source first, JPG behind it, one img element that carries the srcset, sizes, loading, and fetchpriority attributes. The picture element exists precisely so format experiments never break older browsers, per MDN's responsive images guide, and it composes with every attribute above. Our own pipeline measured 72 percent savings moving heroes toward WebP, and the picture element is how those savings ship without cutting off a reader on an older device.

What agents change

An agent that writes pages can apply this whole set mechanically: three sizes generated at build, srcset written from the list, sizes read from the layout, the hero marked eager and high priority, everything else lazy. The judgment calls, which image is the hero, which sizes the design actually renders at, stay human. The attributes are templates. Google's serve-responsive-images guide provides the canonical patterns, and an agent applies them per image in seconds.

Audit one page tonight. Count how many images ship without dimensions, without lazy loading, or at full resolution to every device. Most pages built from templates fail all three. The attributes are already in the HTML spec, the browser does the negotiation, and the bytes you stop shipping are the cheapest performance win on the page.

Sources

The attribute behavior and measurement facts in this post come from these references:

  • MDN documents responsive images end to end: srcset, sizes, picture, and the art-direction use case.
  • web.dev provides the canonical serve-responsive-images patterns and the over-download failure modes.
  • web.dev documents native browser-level lazy loading and its bandwidth behavior.
  • MDN documents the fetchPriority attribute and its effect on resource ordering.

More in Web Design