A DEV Community post compares the WebP and AVIF image formats for image-heavy product pages. Its main advice is to serve AVIF first and fall back to WebP, using the HTML picture element. That element lets a page list several image sources, and the browser uses the first one it supports.
The post leans on MDN Web Docs. According to MDN, AVIF offers much better compression than PNG or JPEG, but it is not quite as well supported as WebP and lacks progressive rendering. That means an image cannot display in stages while it loads. MDN describes WebP as an excellent choice and advises including fallbacks with better browser support. The post adds that AVIF's stronger compression often comes with longer encoding times, which matters if you have many images.
The author also covers related steps. Use the srcset attribute to offer different image sizes for different screens. Add loading="lazy" to delay offscreen images, but not on the main product image, which is likely the Largest Contentful Paint element, the item that sets the page's load-time measurement. For testing, it suggests encoding a few fine-texture images at several quality settings in both formats with the sharp library. Compare the files at full size, record file size and encoding time, and check results with Lighthouse. It also mentions image CDNs such as Cloudinary and Imgix for large-scale work.
A reader comment adds two points. Without a sizes attribute, the browser assumes the image fills the full viewport width, so it may pick a very large file for a small product card. The commenter says this can cost more than the gap between AVIF and WebP. They also recommend setting width and height on the img inside picture so the grid does not jump as images load.
Why it matters
Product pages often carry many photos, so image choices have a large effect on load speed. The post's advice is a low-risk setup: newer, smaller files go to browsers that can use them, and everyone else still gets a working image.
The post also shows that format choice is only part of the job. Image sizing, lazy loading and reserved space can matter as much. Fine-texture photos can behave differently from other images, so testing a few of your own is more reliable than trusting general advice.
Source: DEV Community. This brief summarises their reporting; read the original for the full detail.