Frontend / Web Performance
Art-direct responsive images without shipping two heroes
Use picture, srcset, and sizes to serve meaningful crops on phones and desktops while protecting the first render.

A wide photograph of a workshop can show the speaker, audience and room. The same photograph laid into a narrow phone hero might cut out the speaker, or shrink everyone until it stops telling the story. Resize an image when you need fewer pixels. Make a separate crop when the composition changes.
Give the browser two distinct choices
The browser uses <picture> to select a source for the viewport and srcset to choose a suitable resolution for that source. Keep the descriptive alternative text on the image. Its meaning should still hold when the crop changes. HTML standard for adaptive images
In this example, the workshop subject remains a student presenting to a room. The mobile assets are 4:5 crops. The wide assets are 16:9. Export each listed file with the physical width in its descriptor.
<picture class="workshop-cover">
<source
media="(max-width: 42rem)"
srcset="/media/workshop-phone-480.webp 480w,
/media/workshop-phone-800.webp 800w"
sizes="calc(100vw - 2rem)"
width="800" height="1000"
>
<img
src="/media/workshop-wide-1120.webp"
srcset="/media/workshop-wide-720.webp 720w,
/media/workshop-wide-1120.webp 1120w,
/media/workshop-wide-1600.webp 1600w"
sizes="(max-width: 72rem) calc(100vw - 4rem), 68rem"
width="1120" height="630"
alt="A student presents a workshop exercise to an auditorium"
fetchpriority="high"
>
</picture>
Use CSS whose layout actually matches sizes. In this example the width changes at the same breakpoint as the photo.
.workshop-cover {
display: block;
width: min(calc(100% - 4rem), 68rem);
margin-inline: auto;
}
.workshop-cover img {
display: block;
width: 100%;
height: auto;
}
@media (max-width: 42rem) {
.workshop-cover { width: calc(100% - 2rem); }
}
The sizes values describe the layout slot in CSS pixels. The browser combines that width with device pixel ratio and its resource selection logic. A full-viewport hint for an image that occupies one column will encourage a larger download. Width and height supply an aspect ratio before the file arrives, which prevents the image from pushing nearby text once it loads.
Decide what to load first
The image likely to become Largest Contentful Paint should be discoverable from the initial HTML. Load that image eagerly and consider fetchpriority="high" for the one main photograph. Lazy-load photographs well below the fold. Separate hidden desktop and phone <img> tags can issue two requests, even if only one is displayed. A single <picture> gives the browser the available alternatives within one image element. Google’s guide to optimizing Largest Contentful Paint
If the initial scene dissolves into a WebGL texture, keep a useful HTML image and caption outside the rendering layer. A good static composition also gives visitors something meaningful to see while the effect starts.
Verify the file the browser chose
Open the Network panel with cache disabled. Reload at a mobile viewport, then reload on desktop. Inspect the image's currentSrc and compare the rendered width to the file downloaded. Test at a second device pixel ratio and simulate a slow connection. Check that text and image positions are stable during loading. An oversized candidate may reveal an inaccurate slot size, and a cropped subject calls for another look at the mobile art direction.
Cover illustration by ACM MPSTME.