Image Optimization: Gain Speed with WebP, AVIF and Lazy Loading
Convert your website images to WebP and AVIF formats, implement lazy loading, and improve user experience by reducing page load time.
Elif Demir
Cloud Solutions Architect
Images account for 50-70 percent of an average web page's total size. Unoptimized images dramatically increase page load time. With image optimization, you can significantly improve page speed by switching to WebP and AVIF formats, implementing lazy loading, and using responsive srcset.
WebP and AVIF Formats
WebP, developed by Google, offers 25-35 percent smaller file sizes compared to JPEG. AVIF, derived from the AV1 video codec, is even 20 percent more efficient than WebP. Browser support is over 97 percent for WebP and around 90 percent for AVIF.
| Format | Savings vs JPEG | Browser Support | Encoding Speed |
|---|---|---|---|
| WebP | 25-35% | 97%+ | Fast |
| AVIF | 40-50% | 90%+ | Slow |
| JPEG XL | 35-45% | Limited | Medium |
💡 Tip: Use CDN-level image optimization to automatically convert images to WebP/AVIF. Cloudflare Polish and AWS CloudFront image optimization handle this automatically.
Lazy Loading Implementation
Lazy loading defers loading of off-screen images until the user scrolls to that area. Use the native loading="lazy" HTML attribute, supported by all modern browsers.
⚠️ Important: Do not use lazy loading on the LCP element (hero image, banner). This causes the largest content element to load late and worsens the Core Web Vitals LCP metric.
Responsive Images and srcset
Serving different image sizes for different screen sizes saves bandwidth. Use srcset and sizes attributes to let the browser select the appropriate image. The web.dev responsive images guide provides detailed information. This step is critical for improving your PageSpeed score.
Frequently Asked Questions
Should I use WebP or AVIF?
Serve both using the picture element: AVIF as primary, WebP as fallback, JPEG as last resort. The browser automatically selects the most efficient supported format.
Does image optimization affect SEO?
Yes, directly. Fast-loading images improve Core Web Vitals metrics. Alt text and filename optimization improve image search rankings.
How can I batch convert existing images?
Use Squoosh CLI, Sharp (Node.js), or ImageMagick for batch conversion. For WordPress, ShortPixel or Imagify plugins provide automatic conversion.
After completing image optimization, check our CDN guide and JavaScript performance article.
Hosting with Image Optimization
Optimize your images with automatic WebP conversion and CDN integration on Hosted Cloud servers.
Explore Hosting PlansElif Demir
Cloud Solutions Architect
Specializing in enterprise cloud migration projects and hybrid infrastructure design with 8 years of experience in AWS, Azure, and private cloud environments.
Comments coming soon