How to compress images for the web without ruining them
Most slow pages are not slow because of JavaScript. They are slow because someone uploaded a 4 MB hero image. Fixing that is a five-minute job if you understand three settings.
01First decide the dimensions, then the format
Nothing you do to quality settings recovers the bytes wasted by shipping a 3000-pixel-wide image into a 400-pixel slot. Decide the display width first (multiply by 1.5–2 for retina), then compress. Resizing a 4000×3000 photo to 1200×900 usually removes 80–90% of the bytes before any quality loss is visible.
Try the free Image Resizer02Format: WebP wins, AVIF wins more, JPEG still works
WebP typically cuts 25–35% off an equivalent-quality JPEG and is supported by every current browser. AVIF can cut a further 20–30% on photographs but encodes slowly and needs a fallback for older clients. PNG is for graphics with flat colour, transparency or text — it is a poor choice for photographs. SVG is the only correct answer for logos and icons.
- Photographs: WebP at quality 70–80, AVIF if you control the pipeline.
- Screenshots and UI: PNG, or WebP lossless if you want smaller files.
- Logos and icons: SVG, always.
- Animated content: consider a video instead of a GIF — it is usually 10–50× smaller.
03Quality settings, honestly explained
The quality number in a lossy encoder is not a percentage of anything. It trades precision in the frequency domain: high frequencies (fine texture, sharp edges) are discarded first. Around 80 most photographs are indistinguishable from the original at normal viewing size; 60–70 is fine for background textures; below 50 you start to see blockiness around edges and banding in gradients.
Compressing twice is worse than compressing once — each pass throws away more detail. Always compress from the original, never from an already-optimised file.
Try the free Image Compressor04The workflow that actually saves time
A repeatable loop beats one-off fixes:
- Crop and resize to the largest size the layout will ever use.
- Compress to WebP at quality 75 and check the result at 100% zoom on a real screen.
- If artefacts are visible at normal size, raise quality by 5 rather than starting over.
- Compare the before/after size: a 300 KB photo that looks identical at 90 KB is the goal.
- Serve with width/height attributes (or a responsive srcset) so the layout does not shift while loading.
05Why doing it in the browser matters
Compression tools that upload your files send originals — sometimes including EXIF metadata with GPS coordinates — to a server you do not control. A client-side compressor keeps the file in the tab: read it with FileReader, draw it to a canvas, export with canvas.toBlob. The bytes never travel. That is how ZeroKit's compressor works, and it is also why it keeps working offline.
References
Written for ZeroKit. Every tool mentioned here runs locally in your browser — nothing you paste is uploaded.