Image performance is a delivery problem, not simply a file-compression problem. The right choice balances visual purpose, device width, network cost, browser support and layout stability.

Start with the role of each image

Distinguish photography, diagrams, logos, icons and decorative visuals before choosing a format. A detailed article photograph needs different treatment from a monochrome logo. Converting every visual to one format ignores important differences.

Compare formats on actual assets

Evaluate AVIF, WebP, JPEG, PNG and SVG where technically appropriate using visual inspection. A photo may compress well to WebP while a logo is better as a small SVG. Format names alone do not establish which file will look best.

Deliver appropriate dimensions

A three-column card needs a smaller source than the full-width article hero. Use responsive sources so phones do not download desktop-sized content unnecessarily. Shrinking display dimensions in CSS does not shrink the downloaded file.

Preserve fidelity where meaning matters

Inspect text, interface details, gradients and edge artifacts after optimization. A screenshot of a dashboard may require higher clarity than a soft background photo. Excessive compression can make instructional images unusable.

Reserve stable layout space

Add image dimensions and consistent aspect ratios so surrounding text stays steady. An editorial card grid can use a shared aspect ratio while preserving object-fit crops. Unspecified geometry creates avoidable layout shifts.

Prioritize what the visitor sees first

Load the main hero promptly and defer below-the-fold imagery appropriately. The first featured article photo may need eager loading on a content homepage. Lazy-loading everything can delay the largest visible content element.

Understand the CDN and cache path

Check content negotiation, long-lived asset caching and variant delivery at the edge. A CDN can serve different widths from one source while retaining consistent URLs or variants. Extra transformations can cost time if caching is misconfigured.

Document rights and semantics

Keep meaningful alt text and appropriate permissions alongside the optimized files. A comparison graphic should explain what it shows rather than say image. Performance savings do not override licensing or accessibility.

Check the result in real layouts

A hero crop may hide the subject on narrow devices despite a small file size. Inspect quality and loading over mobile, tablet and desktop, including high-density screens. A fast image that tells the wrong visual story is not an improvement.

Apply this guide

Choose three largest visible images. Record displayed dimensions, file bytes and format, then compare visual quality and loading behavior after resizing each for its actual slot.

Documentation and next reading

Official and primary documentation worth checking for current behavior, requirements and limitations: