Guides · Business
WebP vs AVIF vs JPEG: which image format should your website use?
Compare WebP, AVIF, JPEG and PNG for the web: file size, quality, browser support, encoding speed and how to serve modern formats safely with a fallback.
Key takeaways
- WebP and AVIF usually give much smaller files than JPEG or PNG at similar visual quality.
- AVIF is often smaller than WebP but slower to encode. WebP has wider, longer support.
- Serve modern formats with a fallback using the
<picture>element. - The right size and compression matter as much as the format.
Why format matters
Images are often most of a page's weight. Smaller images load faster, which helps users and your Lighthouse and Core Web Vitals results. See improving a mobile Lighthouse score.
The formats
JPEG is the old standard for photos. Everything supports it. It is lossy and has no transparency.
PNG is lossless and supports transparency. It suits logos and screenshots with flat colours, but photos in PNG are very large.
WebP supports lossy and lossless compression and transparency. It is typically considerably smaller than JPEG or PNG for the same quality, and current browsers support it widely.
AVIF is newer and often compresses even better, especially for photos and gradients. It supports transparency and high dynamic range. Encoding can be slow, and very old browsers do not support it.
Exact savings depend on the image and settings, so test with your own pictures rather than trusting a headline number.
A quick comparison
| JPEG | PNG | WebP | AVIF | |
|---|---|---|---|---|
| Photos, small size | OK | Poor | Good | Very good |
| Transparency | No | Yes | Yes | Yes |
| Support | Universal | Universal | Wide | Wide, newer |
| Encoding speed | Fast | Fast | Fast | Slower |
Check current browser support on a compatibility table before deciding. Support improves over time.
Serve with a fallback
Use <picture> so the browser picks the best format it understands:
<picture>
<source srcset="photo.avif" type="image/avif">
<source srcset="photo.webp" type="image/webp">
<img src="photo.jpg" alt="Describe the image" width="800" height="600" loading="lazy">
</picture>
The <img> fallback also holds the alt, dimensions and lazy loading.
Responsive sizes
Generate several widths, such as 400, 800 and 1200 pixels, and let the browser choose:
<img srcset="photo-400.webp 400w, photo-800.webp 800w, photo-1200.webp 1200w"
sizes="(max-width: 600px) 100vw, 600px"
src="photo-800.webp" alt="..." width="800" height="600">
Automating conversion
Doing this by hand does not scale. Options include:
- Command-line tools such as
cwebpandavifenc. - ImageMagick or libvips in a build or upload step.
- Server-side processing so one upload becomes several optimised files. This is how I handled images for a coaching institute site: one photo upload creates the sizes and formats the pages need.
Practical advice
- Start with WebP everywhere, then add AVIF for large hero images and photos.
- Keep an original high-quality master file.
- Use quality settings around the middle range and compare visually.
- Use SVG for icons and logos where possible.
- Always write useful
alttext.
Frequently asked questions
Should I delete JPEG fallbacks?
If your audience uses current browsers, you might. A fallback costs little, and it protects older devices.
Does the format affect SEO?
Indirectly, through speed, and image search works with all of these formats.
Is AVIF worth the encoding time?
For a few important images, yes. For thousands of user uploads, WebP may be the simpler choice.
The coaching site I built turns one upload into optimised images automatically.
See the coaching site