Why Image Size Matters
Images are usually the heaviest part of a web page. A single unoptimised hero photo can weigh several megabytes, blocking the page from rendering and pushing your Core Web Vitals into the red. Smaller images load faster, cost less bandwidth, and rank better in search engines that factor page speed into their results.
The goal of image optimisation is not to make images as small as possible — it is to make them as small as they can be without a visible drop in quality. Get this right and your pages feel instant; get it wrong and users leave before the content even appears.
Understanding Lossy vs. Lossless Compression
Lossless compression (PNG, lossless WEBP) preserves every pixel — the decoded image is identical to the source. Lossy compression (JPG, lossy WEBP) discards visual information that is hard to perceive, achieving far smaller files at the cost of a small, usually invisible, quality reduction.
For photographs destined for the web, lossy compression is almost always the right call. For graphics where every pixel must stay crisp — logos, text, diagrams — lossless is the safer choice. Matching the compression type to the content is the first step to a small file that still looks good.
Resizing to the Right Dimensions
A common mistake is uploading a full-resolution photo straight from a camera or phone. A 4000px-wide image has no business being served at 1280px display width — the browser still has to download every pixel, then throw most of them away. Resize the image to the largest dimensions it will actually be displayed at, plus a small margin for high-DPI screens (typically 1.5–2× the display width).
Resizing alone often cuts file size by 60–80% with no quality loss at all, because you are simply removing pixels that were never going to be shown. It is the single most effective optimisation step.
Quality Settings Explained
For lossy formats, the quality setting controls how aggressively the compressor discards detail. A quality of 80–85 is the sweet spot for most photographs — the file is a fraction of its original size, and the difference is invisible to the eye. Below 70, banding and blockiness start to appear in smooth areas; below 50, the artefacts are obvious.
Always preview the result at the quality you have chosen. Different images respond differently — a busy, textured photo can tolerate a lower quality than a smooth sky, where artefacts show immediately.
Stripping Metadata
Image files often carry metadata — EXIF camera data, ICC colour profiles, thumbnails, and comments. This data is invisible to the viewer but can add tens or hundreds of kilobytes to every image. Re-encoding an image through a tool like GifLab strips this metadata by default, since the canvas API does not preserve it.
The one caveat: if you rely on embedded colour profiles for accurate colour rendering, stripping them may cause subtle colour shifts on colour-managed displays. For most web images this is irrelevant, but keep it in mind for photography portfolios.
Format Selection for Compression
WEBP produces the smallest files for both photos and graphics on modern browsers — typically 25–35% smaller than JPG at equivalent quality. JPG remains the fallback for maximum compatibility. PNG is reserved for graphics and anything needing transparency. Choosing WEBP over JPG for photographs is the easiest format-level size win available.
For graphics with flat colours, PNG can actually out-compress JPG because JPG's artefacts are visible on sharp edges. When in doubt, export both and compare.
A Practical Workflow
Start with a high-quality source image. Resize it to the display dimensions you need (plus a margin for high-DPI). Convert to WEBP if the target platform supports it, otherwise JPG. Set quality to 80 and preview. If the result is still too large, drop quality in steps of 5 until it looks acceptable, or reduce the dimensions slightly. Save, and ship.
This workflow consistently produces files that are 70–90% smaller than unoptimised originals, with no visible quality loss. Doing it for every image on a site transforms load times.
Measuring the Results
Compare the final file size against the original as a sanity check. A well-optimised web image is usually under 200 KB for a full-width hero and under 50 KB for a thumbnail. If your optimised file is still multiple megabytes, something in the workflow — usually the dimensions — was skipped.
Run the page through a speed test and check the image bytes in the network waterfall. The optimised images should be a small fraction of total page weight, not the dominant cost.