Image delivery combines encoding, dimensions, selection, and loading priority. A smaller transferred file is helpful, but a browser also has to decode the image and fit it into the layout. Start by identifying the displayed size and the image's role on the page. A small thumbnail and the main image above the fold can require different delivery choices even when they show the same subject.

Choose an encoding deliberately

AVIF and WebP are image formats supported by modern browsers. Both can offer smaller files than older encodings for some content and quality settings. The outcome depends on the source image, encoder, and quality target. Compare actual outputs visually and by size instead of assuming that one format always produces the smallest acceptable result.

The picture element can offer alternative formats using source elements with type attributes, followed by an img element. The browser evaluates sources and can choose one it supports. The img element supplies the fallback source and alternative text. A fallback remains useful when a selected format is unavailable, and the alternative text should describe the image's purpose rather than its filename or encoding.

Send appropriate dimensions

Resizing a very large image with CSS does not reduce the number of image bytes downloaded. Generate appropriately sized versions and use srcset to expose candidates. With width descriptors, the sizes attribute describes the expected layout width under different conditions. The browser combines that information with factors such as pixel density when choosing a candidate.

The sizes value should agree with the actual layout. If it substantially overstates the displayed width, the browser may select a larger resource than needed. Test the result at narrow and wide viewports and inspect the selected resource. Pixel density also matters: a device can benefit from more image pixels than the number of CSS pixels occupied by the image.

Specify width and height on img elements to provide an intrinsic aspect ratio. With suitable CSS, the image can still scale to fit its container while the browser reserves space before the file arrives. Reserving that space reduces layout movement caused by a late image. Art-directed sources with different aspect ratios require additional care so that the reserved space matches the selected presentation.

Load according to visibility

The loading="lazy" attribute allows the browser to defer images that are sufficiently far from the viewport. It is useful for content further down a page. The exact loading distance is a browser decision, so lazy loading is not a guarantee that a resource waits until it becomes visible. Explicit dimensions are especially useful for establishing the layout of deferred images.

A likely Largest Contentful Paint image should usually be discoverable in the initial HTML and should not be lazy loaded. The fetchpriority="high" attribute can indicate that an important image deserves higher fetch priority. This is a hint, and applying it to many images weakens the distinction. Priority does not reduce bytes or replace appropriate encoding and dimensions.

Verify the delivered result

Inspect selected sources, transferred sizes, and rendering at representative viewport widths and pixel densities. Check visual quality on detailed and low-contrast areas, confirm useful alternative text, and observe layout shifts. Measure loading with an empty cache as well as repeat visits. These checks reveal whether format, sizing, and loading decisions work together for the actual page.

References