What matters for page speed
The Largest Contentful Paint on most pages is an image, often the hero. Three things help it most, in order: serve it at the size it is displayed (with a 2× version for high-density screens), use a modern format, and do not lazy-load it, since it is visible immediately. Everything below the fold should have loading="lazy" and explicit width and height attributes to prevent layout shift.
A sensible default stack for photos is AVIF with a WebP or JPG fallback in a <picture> element. For icons and logos, inline SVG beats any raster format.
For format trade-offs in more depth, see choosing between JPG, PNG, WebP and AVIF.
Questions people ask
Should I use WebP or AVIF?
AVIF is usually smaller; WebP encodes faster and has a longer support history. Many sites serve AVIF with WebP as the fallback.
What size should website images be?
The largest size they are displayed at, doubled for high-density screens. A full-width hero is typically 1920 to 2400 px wide.
Is Base64 inlining good for performance?
Only for very small images. It adds about a third to the size and cannot be cached separately.