Image Optimization: Formats, Compression & Speed
JPG vs PNG vs WebP vs AVIF - when to use each format and how to optimize images for fast-loading pages.

Your cover image looks perfect—but it's killing your page speed. Large, unoptimized images are the number one cause of slow websites. The solution isn't just compression; it's choosing the right format, size, and delivery method. Here's everything you need to know.
Why Image Optimization Matters
Images typically account for 50-80% of a webpage's total size. Unoptimized images cause:
- Slow page loads - Users leave after 3 seconds
- Poor Core Web Vitals - Google's ranking factor
- High bounce rates - 53% of mobile users abandon slow sites
- Wasted bandwidth - Costs you and your users money
- Bad user experience - Especially on mobile networks
A single unoptimized hero image can add 2-5 seconds to your load time.
Image Formats Explained
JPEG (JPG)
Best for: Photographs and complex images with many colors
JPEG uses lossy compression—it discards some data to reduce file size. You won't notice at reasonable quality levels.
| Pros | Cons |
|---|---|
| Small file sizes | No transparency |
| Universal support | Lossy (quality loss) |
| Great for photos | Artifacts at low quality |
| Adjustable quality | Not ideal for text/graphics |
When to use:
- Cover images (photos)
- Background images
- Any photograph
- Complex illustrations with gradients
Quality settings:
- 80-85%: Best balance of quality and size
- 70-80%: Acceptable for thumbnails
- Below 70%: Visible artifacts
PNG
Best for: Graphics, logos, screenshots, and images needing transparency
PNG uses lossless compression—no quality loss, but larger files than JPEG for photos.
| Pros | Cons |
|---|---|
| Lossless quality | Larger file sizes |
| Transparency support | Overkill for photos |
| Sharp edges | No quality adjustment |
| Great for text/graphics |
When to use:
- Logos and icons
- Screenshots
- Graphics with text
- Images requiring transparency
- Simple illustrations with flat colors
PNG-8 vs PNG-24:
- PNG-8: 256 colors, smaller files, good for simple graphics
- PNG-24: Millions of colors, larger files, full transparency
WebP
Best for: Modern replacement for both JPEG and PNG
WebP is Google's format offering better compression than JPEG and PNG with similar quality.
| Pros | Cons |
|---|---|
| 25-35% smaller than JPEG | Not supported in older browsers |
| Supports transparency | Some CMS limitations |
| Lossy and lossless modes | Less universal than JPEG |
| Animation support |
When to use:
- Any image, with JPEG/PNG fallback
- Modern websites prioritizing speed
- When you can serve multiple formats
Browser support: 97%+ globally (all modern browsers)
AVIF
Best for: Maximum compression with excellent quality
AVIF is the newest format, offering even better compression than WebP.
| Pros | Cons |
|---|---|
| 50% smaller than JPEG | Limited browser support |
| Excellent quality | Slow encoding |
| HDR support | Some CMS don't support |
| Transparency support |
When to use:
- When maximum compression matters
- Progressive enhancement (with fallbacks)
- Future-proofing your site
Browser support: ~93% globally (Chrome, Firefox, Safari 16+)
GIF
Best for: Simple animations only
GIF is outdated for static images but still used for simple animations.
| Pros | Cons |
|---|---|
| Animation support | Only 256 colors |
| Universal support | Large file sizes |
| Poor photo quality |
When to use:
- Simple, short animations
- Never for photographs or cover images
Better alternatives: WebP or MP4 for animations
SVG
Best for: Icons, logos, and simple graphics
SVG is vector-based—it scales infinitely without quality loss.
| Pros | Cons |
|---|---|
| Infinitely scalable | Not for photographs |
| Tiny file sizes | Can be complex to create |
| Editable with CSS/JS | Security considerations |
| Perfect for icons |
When to use:
- Icons and logos
- Simple illustrations
- Graphics that need to scale
- Interactive graphics
Format Decision Tree
Is it a photograph or complex image?
├── Yes → Use WebP (with JPEG fallback)
└── No → Does it need transparency?
├── Yes → Use WebP (with PNG fallback)
└── No → Is it a simple graphic/icon?
├── Yes → Use SVG if possible, else PNG
└── No → Use WebP (with JPEG fallback)
For maximum compatibility:
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description">
</picture>
Compression Fundamentals
Lossy vs Lossless
Lossy compression removes data permanently:
- Smaller files
- Some quality loss (often imperceptible)
- JPEG, lossy WebP, lossy AVIF
Lossless compression preserves all data:
- Larger files
- Perfect quality
- PNG, lossless WebP, GIF
For cover images, lossy compression at 80% quality is almost always the right choice.
Quality Settings
Finding the right quality level:
| Quality | File Size | Visual Quality | Use Case |
|---|---|---|---|
| 100% | Largest | Perfect | Originals only |
| 90% | Large | Excellent | Print, high-end |
| 80-85% | Medium | Very good | Web standard |
| 70% | Small | Good | Thumbnails |
| 60% | Smaller | Acceptable | Low bandwidth |
| Below 50% | Smallest | Poor | Avoid |
The sweet spot for web images is 75-85% quality.
Resolution and Dimensions
Don't serve larger images than needed:
| Display Size | Image Size | Retina Size |
|---|---|---|
| 600px wide | 600px | 1200px |
| 1200px wide | 1200px | 2400px |
| Full width | 1920px | 2560-3840px |
For cover images:
- Standard: 1200 x 630px
- Retina: 2400 x 1260px
- Serve appropriate size based on device
Responsive Images
Serve different sizes to different devices:
<img
src="cover-800.jpg"
srcset="cover-400.jpg 400w,
cover-800.jpg 800w,
cover-1200.jpg 1200w,
cover-2400.jpg 2400w"
sizes="(max-width: 600px) 100vw, 1200px"
alt="Cover image"
>
The browser chooses the appropriate size automatically.
Optimization Workflow
Step 1: Start with the Right Size
Before any compression:
- Determine display dimensions
- Create at 2x for retina (optional)
- Don't upscale—start with larger source
Step 2: Choose the Right Format
- Photo → WebP/JPEG
- Graphic with transparency → WebP/PNG
- Simple icon → SVG
- Animation → WebP/MP4
Step 3: Compress
Use quality 80% for most images. Tools:
| Tool | Best For |
|---|---|
| Squoosh | Maximum control |
| TinyPNG | Quick and easy |
| ImageOptim | Mac batch processing |
| Sharp (Node.js) | Automation |
Step 4: Implement Responsive Serving
- Use
srcsetfor multiple sizes - Use
<picture>for multiple formats - Let the browser choose
Step 5: Lazy Load
Don't load images until needed:
<img src="cover.jpg" loading="lazy" alt="Description">
Native lazy loading is supported in all modern browsers.
Speed Optimization Techniques
Lazy Loading
Load images only when they enter the viewport:
<!-- Native lazy loading -->
<img src="image.jpg" loading="lazy" alt="Description">
<!-- Eager loading for above-fold images -->
<img src="hero.jpg" loading="eager" alt="Hero">
Above the fold: Use loading="eager" (or omit the attribute)
Below the fold: Use loading="lazy"
Preloading Critical Images
Load important images early:
<head>
<link rel="preload" as="image" href="hero.webp" type="image/webp">
</head>
Use for hero/cover images that appear immediately.
Content Delivery Networks (CDN)
CDNs serve images from servers close to users:
| CDN Service | Notes |
|---|---|
| Cloudflare | Free tier, easy setup |
| Imgix | Image-specific, transformations |
| Cloudinary | Full image management |
| Bunny CDN | Affordable, fast |
Benefits:
- Faster delivery globally
- Automatic format conversion
- On-the-fly resizing
- Reduced server load
Image CDNs with Automatic Optimization
Some CDNs optimize images automatically:
<!-- Cloudinary example -->
<img src="https://res.cloudinary.com/demo/image/upload/w_800,q_auto,f_auto/sample.jpg">
<!-- Imgix example -->
<img src="https://example.imgix.net/image.jpg?w=800&auto=format,compress">
They handle format selection, compression, and resizing automatically.
Measuring Performance
Core Web Vitals
Google's metrics that affect ranking:
| Metric | Target | Image Impact |
|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | Hero/cover images |
| CLS (Cumulative Layout Shift) | < 0.1 | Missing dimensions |
| FID (First Input Delay) | < 100ms | Minimal |
Your cover image often IS the LCP element.
Tools for Testing
| Tool | Purpose |
|---|---|
| PageSpeed Insights | Google's official tool |
| Lighthouse | Built into Chrome DevTools |
| WebPageTest | Detailed waterfall analysis |
| GTmetrix | Performance monitoring |
Run tests before and after optimization to measure impact.
What to Look For
- Total image weight - Aim for under 500KB total per page
- Individual image sizes - Cover images under 200KB
- Format usage - Are you serving WebP?
- Responsive images - Different sizes for different devices?
- Lazy loading - Are below-fold images deferred?
Common Mistakes
1. Uploading Unoptimized Images
CMS uploads don't always optimize. Always compress before uploading.
2. Wrong Format Choice
Using PNG for photographs wastes bandwidth. Use JPEG/WebP.
3. Serving Desktop Images to Mobile
A 2400px image on a 375px phone is wasteful. Use responsive images.
4. Missing Width and Height
Without dimensions, images cause layout shift:
<!-- Bad: causes CLS -->
<img src="image.jpg" alt="Description">
<!-- Good: prevents CLS -->
<img src="image.jpg" width="1200" height="630" alt="Description">
5. Not Lazy Loading
Loading all images upfront slows initial page load. Lazy load below-fold images.
6. Ignoring Modern Formats
WebP has 97% browser support. Not using it leaves performance on the table.
Platform-Specific Tips
WordPress
- Use plugins like ShortPixel, Imagify, or Smush
- Enable WebP conversion
- Use lazy loading (native in WP 5.5+)
Next.js
- Use the
next/imagecomponent - Automatic optimization and WebP
- Built-in lazy loading
Ghost
- Automatic responsive images
- Use Ghost Pro for CDN
- Compress before upload
Static Sites
- Build-time optimization (Sharp, imagemin)
- Generate multiple formats
- Use
<picture>elements
Quick Reference
Optimal Settings for Cover Images
| Property | Recommendation |
|---|---|
| Format | WebP with JPEG fallback |
| Dimensions | 1200 x 630px (2400 x 1260 for retina) |
| Quality | 80% |
| File size | Under 200KB |
| Loading | Eager (above fold) |
Format Comparison
| Format | Best For | Compression | Transparency | Support |
|---|---|---|---|---|
| JPEG | Photos | Lossy | No | 100% |
| PNG | Graphics | Lossless | Yes | 100% |
| WebP | Both | Both | Yes | 97% |
| AVIF | Both | Both | Yes | 93% |
| SVG | Icons | N/A | Yes | 100% |
FAQ
Q: Should I always use WebP?
Use WebP with fallbacks. While support is 97%+, JPEG/PNG fallbacks ensure everyone sees your images.
Q: How much can optimization really save?
Typically 50-80% file size reduction with no visible quality loss. A 500KB JPEG can often become a 100KB WebP.
Q: Does Next.js/Vercel optimize images automatically?
Yes, next/image handles format conversion, resizing, and optimization automatically. Still provide reasonable source images.
Q: What about SVG for cover images?
SVG is for graphics, not photographs. Cover images are typically photos, so use WebP/JPEG.
Q: How do I know if my images are the problem?
Run PageSpeed Insights. It specifically flags image issues and estimates potential savings.
Find Fast-Loading Cover Images
Great images shouldn't slow down your site. CoverImage.app provides properly sized, optimized images ready for web use—no post-processing needed.
Ready to find your perfect cover image?
Try CoverImage.app - paste your content, get AI-matched images instantly.
Try it Free