Prompt
best way to compress images for web
Latest observation
Nov 3, 2026
OpenAI APIWeb search: off
The best way to compress images for the web is usually:
-
Use the right format
- JPEG/WebP/AVIF for photos
- PNG/WebP for images needing transparency
- SVG for logos, icons, illustrations
- AVIF is usually the smallest, but browser support and encoding speed can be tradeoffs
- WebP is a great default for broad support and good compression
-
Resize before compressing
- Don’t upload a 4000px-wide image if it only displays at 800px
- Scale images to the largest size they’ll actually be shown
-
Use lossy compression when possible
- For photos, lossy compression gives the biggest file size reduction
- Start with quality around:
- JPEG/WebP: 70–85
- AVIF: often 40–60 works well
- Adjust based on visual quality
-
Strip unnecessary metadata
- Remove EXIF data, thumbnails, color profiles if not needed
-
Use responsive images
- Serve different sizes using
srcsetandsizes - This helps mobile devices load smaller files
- Serve different sizes using
-
Automate optimization
- Tools: Squoosh, ImageMagick, Sharp, ImageOptim, TinyPNG, libvips
- In build pipelines, generate multiple sizes and formats automatically
Practical recommendation
- Photos: AVIF first, fallback to WebP, then JPEG
- Icons/logos: SVG
- Transparent graphics: WebP or PNG if necessary
- Always resize to display dimensions first
If you want, I can give you:
- a tool-by-tool workflow
- command line examples
- or the best settings for JPEG/WebP/AVIF.