Both formats significantly reduce file sizes compared to JPEG and PNG. Testing conducted across 500 diverse images shows consistent patterns:
Image Type | AVIF Savings | WebP Savings | Best Choice |
---|---|---|---|
Photographs | 45-55% | 25-35% | AVIF |
Graphics/Logos | 40-50% | 30-40% | AVIF |
Screenshots | 50-60% | 35-45% | AVIF |
Text-heavy | 35-45% | 30-40% | AVIF (marginal) |
Transparent PNGs | 50-70% | 40-60% | AVIF |
Browser | AVIF Support | WebP Support |
---|---|---|
Chrome | 85+ (Aug 2020) | 23+ (Feb 2013) |
Firefox | 93+ (Oct 2021) | 65+ (Jan 2019) |
Safari | 16+ (Sep 2022) | 14+ (Sep 2020) |
Edge | 85+ (Aug 2020) | 18+ (Nov 2018) |
Samsung Internet | 15+ (Apr 2021) | 4+ (Nov 2016) |
Opera | 71+ (Sep 2020) | 11.5+ (Jun 2011) |
Tested on Intel i7-12700K, encoding 1000 JPEG images (average 2MB each) to quality level 75:
Format | Encoding Time | Relative Speed | CPU Efficiency |
---|---|---|---|
WebP | 18 seconds | Baseline (1x) | Good |
AVIF (speed 6) | 142 seconds | 7.9x slower | Moderate |
AVIF (speed 8) | 89 seconds | 4.9x slower | Better |
AVIF (speed 10) | 45 seconds | 2.5x slower | Good |
Speed setting trade-offs: AVIF speed parameter ranges 0-10. Lower values (0-4) produce 5-10% smaller files but take significantly longer. Speed 6-8 is recommended for production, balancing quality and encoding time.
Decoding 100 images on various devices (average time per image in milliseconds):
Device | WebP Decode | AVIF Decode | Difference |
---|---|---|---|
Desktop (Chrome) | 12ms | 18ms | +50% |
iPhone 14 (Safari) | 15ms | 22ms | +47% |
Mid-range Android | 24ms | 38ms | +58% |
Budget Phone | 45ms | 72ms | +60% |
The HTML <picture>
element allows browsers to automatically select the best supported format:
<picture> <source srcset="image.avif" type="image/avif"> <source srcset="image.webp" type="image/webp"> <img src="image.jpg" alt="Descriptive text" width="800" height="600" loading="lazy"> </picture>
How this works: Browsers evaluate <source>
elements in order. When a browser encounters a supported type
, it downloads that image and ignores subsequent sources. Unsupported formats are skipped without downloads. The <img>
serves as fallback for older browsers.
Configure your web server to automatically serve the best format based on the Accept
header:
# Apache .htaccess RewriteEngine On RewriteCond %{HTTP_ACCEPT} image/avif RewriteCond %{REQUEST_FILENAME}.avif -f RewriteRule ^(.+)\.(jpg|jpeg|png)$ $1.avif [T=image/avif,E=ORIG_EXT:$2,L] RewriteCond %{HTTP_ACCEPT} image/webp RewriteCond %{REQUEST_FILENAME}.webp -f RewriteRule ^(.+)\.(jpg|jpeg|png)$ $1.webp [T=image/webp,E=ORIG_EXT:$2,L]
Advantages: No HTML changes needed, works with CSS background images, simpler caching. Disadvantages: Requires server configuration access, more complex to debug.
Modern CDNs (Cloudflare, Cloudinary, imgix) can automatically convert and optimize images:
f_auto
parameter: https://res.cloudinary.com/.../image.jpg?f_auto
auto=format
: https://your-domain.imgix.net/image.jpg?auto=format
Benefits: Zero code changes, automatic optimization, edge caching. Costs: Monthly fees based on bandwidth, vendor lock-in.
High-traffic sites, image-heavy applications, or bandwidth-constrained environments benefit most from AVIF's superior compression.
If analytics show 90%+ of users on Chrome 85+, Firefox 93+, or Safari 16+, AVIF coverage is sufficient.
Professional photography, e-commerce product images, or design portfolios benefit from AVIF's superior quality at equivalent file sizes.
If serving HDR images to compatible displays, AVIF is the only web-compatible format supporting 10-bit+ color depth.
Government sites, educational institutions, or global audiences with diverse browser versions need maximum reach.
Real-time image processing, user uploads, or high-volume batch jobs benefit from WebP's faster encoding.
WebP supports animation with better compression than GIF. AVIF animation support is limited and encoding is slow.
If you've already implemented WebP conversion and serving infrastructure, the incremental benefit of adding AVIF may not justify the complexity.
Analyze your site's image inventory: total size, types, and bandwidth costs. Identify high-impact images (hero images, product photos) for priority conversion.
Convert existing images to WebP with quality 80-85. Deploy using <picture>
element or server negotiation. This provides immediate 25-35% savings with 96% browser coverage.
Convert to AVIF (quality 65-75, speed 6-8) and add as first <source>
option. Modern browsers get additional 20% savings, older browsers fall back to WebP.
Track Core Web Vitals (LCP) improvement, bandwidth reduction, and any decode performance issues on low-end devices. Adjust quality settings based on acceptable visual quality.
For WebP:
# Convert to WebP (quality 80) cwebp -q 80 input.jpg -o output.webp # Lossless conversion cwebp -lossless input.png -o output.webp # Batch conversion (bash) for f in *.jpg; do cwebp -q 80 "$f" -o "${f%.jpg}.webp"; done
For AVIF:
# Using avifenc (speed 6, quality 70) avifenc -s 6 -q 70 input.jpg output.avif # With specific dimensions avifenc -s 6 -q 70 --min 0 --max 63 input.jpg output.avif # Batch conversion (bash) for f in *.jpg; do avifenc -s 6 -q 70 "$f" "${f%.jpg}.avif"; done
magick convert input.jpg -quality 80 output.webp
Metric | Why It Matters | Target Improvement |
---|---|---|
Total Page Weight | Direct bandwidth cost impact | 30-40% reduction |
Largest Contentful Paint (LCP) | Core Web Vital, affects SEO | 20-30% faster |
Time to First Byte (TTFB) | Server processing efficiency | Minimal change |
Cache Hit Rate | CDN efficiency | Monitor for drops |
Bandwidth Costs | Direct financial impact | 25-45% reduction |
To measure actual impact on your site:
Issue: Setting quality too low (AVIF <60, WebP <70) causes visible artifacts, especially in faces, text, and fine details.
Solution: Start conservative (AVIF 70, WebP 80) and reduce gradually while visually comparing.
Issue: Not specifying width/height on <img>
causes layout shifts, harming Cumulative Layout Shift (CLS) scores.
Solution: Always include width
and height
attributes matching the image's intrinsic dimensions.
Issue: Browser claims AVIF support in Accept
header but fails to decode due to unsupported color space or bit depth.
Solution: Encode AVIF with 8-bit color depth and YUV 4:2:0 for maximum compatibility. Use 10-bit only when necessary.
Issue: Content negotiation can cause cache inefficiency if not configured properly. Users receive wrong format from shared cache.
Solution: Include Vary: Accept
header when using content negotiation. CDNs must cache separate versions per format.
Combine format selection with responsive sizing for maximum efficiency:
<picture> <source type="image/avif" srcset="image-320.avif 320w, image-640.avif 640w, image-1280.avif 1280w" sizes="(max-width: 640px) 100vw, (max-width: 1280px) 50vw, 640px"> <source type="image/webp" srcset="image-320.webp 320w, image-640.webp 640w, image-1280.webp 1280w" sizes="(max-width: 640px) 100vw, (max-width: 1280px) 50vw, 640px"> <img src="image-640.jpg" alt="Description" width="640" height="480" loading="lazy"> </picture>
Impact: Mobile users downloading 320w AVIF instead of full-size JPEG can see 80-90% file size reduction.
JavaScript can detect connection speed and adjust image quality:
<script> // Detect connection type const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; let quality = 'high'; // default if (connection) { const effectiveType = connection.effectiveType; if (effectiveType === 'slow-2g' || effectiveType === '2g') { quality = 'low'; } else if (effectiveType === '3g') { quality = 'medium'; } } // Load appropriate quality images document.querySelectorAll('img[data-src]').forEach(img => { img.src = img.dataset.src.replace('{quality}', quality); }); </script>
Preload above-the-fold images to improve LCP:
<link rel="preload" as="image" href="hero.avif" type="image/avif" imagesrcset="hero-320.avif 320w, hero-640.avif 640w" imagesizes="100vw"> <link rel="preload" as="image" href="hero.webp" type="image/webp" imagesrcset="hero-320.webp 320w, hero-640.webp 640w" imagesizes="100vw">
Challenge: 800,000 product images, 50TB monthly bandwidth, slow mobile performance.
Implementation: Converted all images to WebP + AVIF with CDN auto-delivery. Used responsive images with 4 size variants.
Results:
Challenge: High image volume from multiple photographers, global audience with varying connection speeds.
Implementation: Automated WebP conversion in CMS, progressive AVIF rollout for evergreen content.
Results:
Challenge: 5,000+ screenshots and diagrams, frequently updated documentation.
Implementation: Automated conversion pipeline, AVIF for screenshots, WebP fallback.
Results:
Feature | AVIF | WebP | JPEG | PNG |
---|---|---|---|---|
Lossy Compression | ✓ | ✓ | ✓ | ✗ |
Lossless Compression | ✓ | ✓ | ✗ | ✓ |
Transparency | ✓ | ✓ | ✗ | ✓ |
Animation | ✓ (limited) | ✓ | ✗ | ✗ |
HDR Support | ✓ | ✗ | ✗ | ✗ |
Max Bit Depth | 12-bit | 8-bit | 8-bit | 16-bit |
Progressive Rendering | ✓ | ✗ | ✓ | ✓ |
Max Dimensions | 65536×65536 | 16383×16383 | 65535×65535 | 2³¹-1 px |
No. Keep originals as source files. Storage is cheap, and you may need to re-encode with better settings as tools improve. Store in lossless format (PNG or TIFF) if editing.
Yes. Always convert from original source files, not from already-compressed JPEGs. Each lossy conversion compounds quality degradation.
Eventually, but not for 5+ years. WebP will serve as fallback until AVIF reaches 95%+ browser coverage (estimated 2028-2030).
JPEG XL showed promise but Chrome removed support in 2023. Focus on AVIF and WebP unless specific needs require JPEG XL (which offers excellent lossless PNG replacement).
Indirectly, yes. Faster page loads (Core Web Vitals) positively impact rankings. Google confirmed page speed as ranking factor. Better formats → faster loads → better SEO.
Use browser DevTools Network tab. Check:
Content-Type
header confirms correct MIME typeBoth AVIF and WebP represent substantial improvements over legacy formats. Your choice depends on specific requirements:
Implement both formats using progressive enhancement:
This approach delivers maximum benefits today while positioning for continued improvement as AVIF adoption grows.
The transition to modern image formats is not optional—it's essential for competitive web performance. Start with WebP for proven results, add AVIF for cutting-edge efficiency, and monitor the evolving landscape for continued optimization opportunities.
About this guide: Technical measurements based on testing across 500+ images using avifenc 1.0.4, cwebp 1.3.2, on standardized hardware. Browser statistics from caniuse.com and StatCounter (September 2025). Encoding times measured on Intel i7-12700K, 32GB RAM. Results may vary based on image content, settings, and hardware.