Short answer: Keep JPEG as a dependable photographic fallback, add WebP for broad modern efficiency, and consider AVIF when your corpus shows worthwhile savings at acceptable visual quality and processing cost. Negotiate or declare formats through a cache-safe delivery policy.
No format wins every image. A codec that compresses photographs extremely well may perform differently on illustrations, screenshots, gradients, transparency, or tiny thumbnails. The right decision is a tested policy, not a single benchmark copied from another site.
What differs between the formats?
JPEG is mature, universally supported for photographic delivery, quick to encode, and well understood. It does not support alpha transparency and can show blocking or ringing at aggressive settings. Progressive JPEG can improve perceived loading in some contexts.
WebP supports lossy and lossless modes, transparency, and animation. Browser support is broad, and many image platforms provide efficient WebP output. It is a practical modern default for mixed web content when a compatible fallback exists.
AVIF supports advanced compression, alpha, and high dynamic range capabilities. It can produce smaller photographic files at comparable perceived quality, but encode cost and artifact behavior vary by content and settings. Support must be considered for the browsers, webviews, crawlers, and downstream tools your application actually serves.
MDN maintains current compatibility and format characteristics in its image file type guide. Use that as a living reference rather than relying on old support assumptions.
How should you compare quality?
Do not compare quality numbers across formats. A value of 70 is not a portable visual target between JPEG, WebP, AVIF, or different encoders. Generate candidates at several settings, then compare both visual output and size.
Build a corpus with portraits, landscapes, products, dark scenes, fine texture, gradients, screenshots, illustrations, transparency, and text within images. Test the real delivery dimensions because resizing can change which artifacts are visible.
Use perceptual metrics as screening tools, then visually review business-critical classes at rendered size. Watch for smearing, edge halos, color shifts, banding, loss of fine text, and slow decode on constrained devices. The guide to automatic quality describes how to operationalize these thresholds.
Explicit format or content negotiation?
With explicit format URLs, markup or application logic requests .avif, .webp, or .jpg. A <picture> stack can give the browser ordered choices. The URLs are easy to reason about and cache independently, but candidate markup can become large when mixed with art direction and many widths.
With automatic negotiation, one visible URL returns a supported format based on request capabilities. This simplifies markup but makes cache configuration critical. The response must vary safely so an AVIF-capable client’s object is not served to an incompatible client.
Cloudinary describes automatic format selection in its image optimization documentation. Cloudflare documents format behavior in its image transformation options. Verify the exact provider and CDN interaction through requests, not only configuration screens.
Does the smallest file always improve performance?
Transfer size matters, especially on slow connections, but it is one part of the path. A format can cost more to encode on the cold transformation path, take more CPU to decode, or delay availability if generated on demand. A slightly larger warm object may outperform a smaller derivative that is constantly regenerated because of a fragmented key.
Measure time to first byte, transfer duration, decode impact where available, and the page’s user-facing metrics. For an LCP hero, early discovery and correct dimensions can have more impact than a modest codec difference. The LCP image guide helps prioritize those factors.
What fallback policy is robust?
Always retain a broadly compatible representation for clients and integrations that cannot consume the preferred format. Confirm that social card fetchers, email clients, PDF generators, native webviews, and third-party consumers do not depend on a format they fail to decode.
If automatic negotiation fails or the preferred encode errors, define whether the service falls back to another format or returns an error. Silent fallback is resilient but should be observable through Content-Type and metrics.
Preserve PNG or another lossless path where transparency, sharp interface graphics, or archival requirements justify it. This comparison is focused on photographic delivery, not a rule to convert every file.
How do you ship the policy?
Create a versioned format preset and roll it out by asset class or page cohort. Record output content type, bytes, transform latency, cache hit ratio, and visual review results. Use the payload waste measurement guide to compare selected resources in real layouts.
Keep rollback simple through versioned URLs or a policy flag. Re-run the corpus when encoders, provider behavior, browser mix, or content mix changes.
The best format policy is conditional and measurable: known fallback, modern alternatives where they help, correct cache variation, and quality thresholds derived from the images your users actually see.

Leave a Reply