Image guide
Image Compression for Web Performance: A Practical Guide
On most websites, images are the single heaviest thing a visitor downloads — heavier than the HTML, CSS, and JavaScript combined. Shrinking them is usually the fastest, cheapest performance win available. This guide explains why images dominate page weight, how to pick the right format, how lossy and lossless compression actually differ, and the step-by-step workflow for optimizing a whole site without visibly harming quality.
Open the image compressorWhy images are the #1 page-weight culprit
Open any page-speed report and the same pattern appears: images account for half or more of the total bytes on a typical page. A single unoptimized hero photo straight from a camera can weigh 4 to 8 MB, while the rest of the page — text, styles, scripts — might total under 1 MB. Every one of those bytes has to travel over the visitor's connection before the page feels complete, and on mobile networks that is the difference between a page that appears instantly and one that visibly stutters in.
This is where Largest Contentful Paint, or LCP, comes in. LCP is one of Google's Core Web Vitals — the small set of metrics Google uses to judge real-world page experience — and it measures how long it takes for the largest visible element on screen to finish rendering. On most pages that element is an image: the hero banner, a product photo, a featured thumbnail. A heavy image pushes LCP later, and a late LCP means both frustrated visitors and a weaker page-experience signal for search rankings. The good news is the inverse: cutting image weight is often the single biggest lever you have on LCP, bigger than any code tweak.
The reason images balloon is rarely mysterious. Photos uploaded straight from phones or stock sites arrive at full camera resolution (often 4000+ pixels wide), in an inefficient format, with no compression applied. A page that displays that photo at 800 pixels wide is downloading roughly twenty-five times more pixels than it shows. Fixing that waste — resizing, choosing a modern format, and compressing — can turn a 5 MB image into 150 KB with no visible difference. Multiply that across a homepage with ten images and you have removed tens of megabytes from every single visit.
Choose the right format first
Format choice comes before compression, because no amount of compression fixes a fundamentally wrong format. A photograph saved as PNG can be ten times heavier than the same photo as a compressed JPEG; a logo saved as JPEG gets ugly smudges around its edges that PNG or WebP would avoid. Pick the format for the content, then compress within it.
| Format | Best for | Watch out for |
|---|---|---|
| JPEG | Photographs and complex realistic images | No transparency; blocky artifacts on sharp edges and text if over-compressed |
| PNG | Logos, icons, graphics with text, anything needing transparency | Much larger than JPEG for photos — never use it for photographic content |
| WebP | Almost everything on the modern web: photos and graphics, with or without transparency | Unsupported only in very old browsers; otherwise the safest modern default |
| AVIF | Large hero photos where every kilobyte counts | Slower to encode; check your audience's browsers before relying on it exclusively |
The practical rule of thumb: photos go to JPEG or WebP, graphics with transparency go to PNG or WebP, and WebP is the best default for both when your audience uses modern browsers — it is typically 25–35% smaller than an equivalent-quality JPEG and handles transparency that JPEG cannot. AVIF squeezes files even further and is excellent for big above-the-fold photos, but treat it as a specialist tool rather than a wholesale replacement: encoding takes longer, and a small share of older browsers cannot display it. Whatever you choose, the key mistake to avoid is the photo-as-PNG, which is the single most common source of multi-megabyte images on the web.
Compression: lossy vs lossless, explained practically
Compression comes in two flavors, and the difference matters more in practice than in theory. Lossless compression shrinks a file without discarding any image data — what comes out is pixel-identical to what went in. PNG uses lossless compression, which is why it is perfect for logos and screenshots but terrible for photos: photographic detail simply does not compress losslessly to small sizes. Lossy compression, used by JPEG, WebP, and AVIF, deliberately discards visual information the human eye is unlikely to notice — subtle color gradations, fine high-frequency detail — and that is what makes dramatic size reductions possible.
In practice, the workflow is straightforward. For photographs, use lossy compression and pick a quality level where the image looks identical to the original at normal viewing distance. There is a reliable way to find that level: compress, open the result at 100% zoom, and look at areas with fine detail — hair, fabric texture, foliage, gradients in a sky. If you can see blockiness, smearing, or banding, you went too far; back off one step. For most web photos the sweet spot removes 60–80% of the file weight with no visible change. For graphics containing text, logos, or sharp lines, stay lossless (PNG or lossless WebP) or keep lossy quality high — text is where compression artifacts show first and look the most unprofessional.
Two cautions. First, lossy compression is cumulative: every time you re-save a JPEG as a JPEG, quality degrades a little more. Always compress from the original source file, never from an already-compressed copy — keep your masters untouched and generate web versions from them. Second, do not judge quality on a thumbnail. Artifacts hide at small sizes and ambush you on a large monitor or a high-density phone screen, so always preview at full size before publishing.
Resize before you compress
The most wasteful images on the web are not badly compressed — they are oversized. A 4000-pixel-wide photo displayed in an 800-pixel-wide slot forces every visitor to download five times more pixels in each dimension, roughly twenty-five times the data, for zero visual benefit. Resizing to the display size first is the highest-leverage step in the whole workflow, and it must come before compression: compressing first and resizing second wastes effort and can bake artifacts into the smaller image.
The rule is "serve scaled images": no image should be much larger than the largest size at which it will ever be displayed. Check your layout — a full-width hero on desktop might need 1600 to 1920 pixels wide, a content-column image 800 to 1200, a thumbnail 300 to 600. For crisp rendering on high-density ("retina") screens, serving up to twice the CSS display size is reasonable; beyond 2x the returns are invisible and the bytes are pure waste. Resize with the image resizer, choosing the target dimensions from your actual layout, and only then run the result through the image compressor. Both tools run entirely in your browser, so even a folder of dozens of images can be processed without uploading anything.
One more source of oversized images deserves a mention: PDF pages converted to images for the web. A PDF page rendered at print resolution becomes an enormous image file; converting pages with a tool like PDF to WebP and then resizing to the display size keeps document previews fast instead of turning each page into a multi-megabyte download.
Responsive images and lazy loading basics
Resizing to one size solves the desktop case, but a phone on a 4G connection should not download the same 1920-pixel hero as a desktop on fiber. Responsive images solve this by giving the browser several pre-sized versions of the same image and letting it pick the smallest one that looks sharp on the visitor's screen. In HTML this is done with the srcset attribute: you list the image at multiple widths (say 480, 960, and 1920 pixels), and the browser downloads only the appropriate one. Most modern site builders and content management systems generate these versions automatically when you upload an image — WordPress, for example, has created responsive srcset versions out of the box for years — but the versions are only as good as the original: uploading an already-optimized WebP means every generated size is small too.
Lazy loading handles the other half of the problem: images further down the page. By default, browsers download every image on a page immediately, including ones the visitor may never scroll to. Adding loading="lazy" to an image tag tells the browser to wait until the image is about to enter the viewport before downloading it. The effect on initial page weight is dramatic on image-heavy pages — a long article with twenty images might download only the first three on arrival. Apply lazy loading to every image except the ones visible on first screen (the hero or LCP image), which should load eagerly so the page paints as fast as possible. Combined with responsive sizes, this means each visitor downloads only the pixels they actually see, at a size suited to their device.
A practical workflow checklist for a whole site
Optimizing one image is a chore; optimizing a whole site is a process. Run through this checklist top to bottom and you will catch the big wins first, where a small number of fixes removes most of the weight.
- ✓Audit first: run your key pages through a speed test and list the heaviest images — fix the homepage and top landing pages before touching the long tail.
- ✓Assign each image a format: photos to WebP (or JPEG), graphics and logos with transparency to WebP or PNG — and convert any photo currently saved as PNG.
- ✓Resize every image to its largest display size (up to 2x for high-density screens) with the image resizer — before compressing, never after.
- ✓Compress from the original masters with the image compressor; preview at 100% zoom and keep the highest quality that still looks identical.
- ✓Serve responsive sizes (srcset) so phones get small files and desktops get large ones — let your CMS generate them from the optimized originals.
- ✓Lazy-load every below-the-fold image; keep the hero image eager so Largest Contentful Paint stays fast.
- ✓Set a rule for future uploads: maximum dimensions, WebP preferred, no photo-as-PNG — so the site stays fast instead of slowly regressing.
- ✓Re-test after the pass and compare LCP and total page weight before and after — the numbers are the proof the work mattered.
One final reassurance for anyone handling client work: because the compressor and resizer run entirely in your browser, the images you optimize never leave your device. There is no upload queue, no account, and no copy stored on a server — which makes this workflow as safe for confidential client assets as it is for your own photos.
Frequently asked questions
Will compressing my images make them look blurry?
Not if you compress sensibly. Moderate lossy compression on photos is visually identical to the original at normal viewing distance; visible damage only appears when you push compression too far. Preview the result at full size and dial back if you can spot artifacts.
Should I use WebP or AVIF for my website?
WebP is the safe default: it is supported by virtually all modern browsers and noticeably smaller than JPEG or PNG. AVIF compresses even further and is great for large photos, but encoding is slower and very old browsers lack support, so use it selectively rather than everywhere.
Do I need to both resize and compress my images?
Yes, and in that order. Resizing removes wasted pixels first, then compression shrinks what remains. Compressing a 4000-pixel image that displays at 800 pixels is working five times harder than necessary and still ships oversized bytes.
Is it safe to compress client images in a browser tool?
Yes. A browser-based compressor processes everything on your own device, so client files are never uploaded to a server or stored anywhere. You get optimized images back with no copy left behind.