Image compression reduces the data needed to deliver an image. For SEO work, the goal is a page that loads efficiently while preserving the visual information readers need. No format is universally best: photographs, transparent graphics, screenshots and diagrams have different requirements.
First separate dimensions, encoding and delivery
Resizing changes pixel dimensions. Compression changes how the image is encoded and, for lossy settings, how much visual information is discarded. Responsive delivery chooses an appropriate resource for the display. A site often needs all three rather than repeatedly recompressing one oversized file.
For example, a product photo used in a small card does not always need the same resource as a zoomable detail view. The detail view may still need the original resolution. Keep a high-quality master and generate derivatives for their actual uses.
Lossy and lossless compression
Lossless compression preserves the decoded pixel information represented by the input to that encoding step. It can suit diagrams, sharp text and assets where exact detail matters. Lossy compression discards some information to reduce size; acceptable settings depend on the content and viewing conditions.
Saving a previously damaged JPEG into a lossless format cannot restore discarded detail. Avoid repeated lossy exports from successive derivatives. Compare candidates against the master, especially around small text, fine edges, gradients and product features that affect identification.
Choose formats by the picture's job
The MDN image-format guide describes format capabilities and compatibility. Use those capabilities to shortlist candidates, then test the actual image and clients you need to support; a format name alone is not a quality decision.
| Content | Formats to compare | What to inspect |
|---|---|---|
| Product or scene photograph | AVIF, WebP and JPEG | Texture, edges, colour, file size and supported clients |
| Screenshot with small text | PNG or lossless WebP; carefully tested lossy options | Legibility at the actual reading size |
| Logo or simple vector diagram | SVG when a genuine vector source is available | Rendering, accessibility and safe handling of the SVG content |
| Transparent raster asset | WebP, AVIF or PNG | Alpha edges against the actual page background |
| Long or photographic animation | Compare suitable video delivery with animated image options | Playback controls, motion, poster and total transfer cost |
Modern formats can be effective, but compare the actual output rather than assuming a fixed saving. An SVG containing an embedded large photograph does not gain the benefits of a simple vector drawing merely from its filename.
The picture-element guide shows how to provide alternative formats with an img fallback. Responsive size selection and art direction are separate choices: changing the crop can help mobile reading, but should not remove an important product detail.
<picture>
<source srcset="pump.avif" type="image/avif">
<source srcset="pump.webp" type="image/webp">
<img src="pump.jpg" alt="Side view of the pump and its inlet connection"
width="960" height="640" decoding="async">
</picture>
This is a teaching example. Supply the actual files, dimensions and alternative text for your image; a filename extension alone does not convert the file. The browser selects the first supported source, rather than comparing their visual quality for you.
A repeatable compression comparison
- Choose the original asset and note its role, required crop and intended display sizes.
- Generate candidates at appropriate dimensions, changing one relevant setting at a time.
- Compare file size and inspect visible defects at the real desktop and phone sizes.
- For technical images, read every label and confirm the important geometry remains clear.
- Publish a selected derivative and verify which resource the browser actually downloads.
- Measure the affected page under comparable conditions before drawing a performance conclusion.
A useful record contains the source filename, output format, pixel dimensions, encoding setting, resulting bytes and visual decision. Do not compare formats using different crops or resolutions and describe the entire difference as a codec saving. A “quality 75” setting is also not guaranteed to mean the same thing across encoders.
A local example: smaller does not mean the same pixels
This example uses one original, AI-assisted synthetic calibration image containing a gradient, fine lines and small labels. It is not a product photo or customer result. All four files use the same 960 × 640 RGB input without resizing or changing the crop. Actual file sizes were measured locally with Pillow 12.3.0 and libwebp 1.6.0.
| Output | File bytes | Decoded RGB equals master? |
|---|---|---|
| PNG master | 54,259 | Yes |
| WebP lossless | 31,870 | Yes |
| WebP quality 30 | 21,932 | No |
| JPEG quality 30 | 34,277 | No |
The PNG master was saved with optimization enabled. Both WebP exports used method 6; the lossless export enabled lossless mode, while the lossy export used quality 30. The JPEG export used quality 30, 4:2:0 chroma subsampling and optimization. Those two quality-30 settings are not equivalent perceptual-quality targets. AVIF was not measured in this example.

For this single graphic, lossless WebP is smaller than the lossy JPEG while reproducing the master RGB pixels exactly. The smaller lossy WebP is not pixel-identical. That is a result for these files and settings, not a rule that lossless always beats lossy or that one codec wins for every photograph.
The close-up shows why label edges and line colours need inspection. Pixel equality is a precise check for this RGB example; it is not a full assessment of colour profiles, metadata, transparency or perceived quality. File bytes also differ from total network-transfer costs. Repeat the comparison on your real assets before choosing a production setting.
Deliver the selected image correctly
Supply appropriate srcset and sizes where multiple resource widths are available. Match the intended display width and account for device pixel density; a 390-pixel viewport does not automatically mean a 390-pixel source is adequate. Set intrinsic dimensions or a stable aspect ratio to reserve space. Use descriptive alt text for meaningful images, and retain nearby captions explaining the image's real context. For product views and controls, see the ecommerce image alt-text guide.
Lazy loading is useful for suitable below-the-fold images, but do not delay the image that is actually needed for the initial view or identified as the LCP element. The LCP optimization guide explains why discovery, priority and rendering delays matter as well as file size; do not set every image to high priority. Google's image guidance also covers crawlable image references, supported formats and text context. A small file alone does not ensure Google can discover it.
After replacing an asset, verify its final URL, response, content type, cache behavior and visible image. Confirm that a CDN or image service is not still serving an older derivative or an unexpected oversized version.
Use tools for the question they answer
Squoosh can help compare encodings interactively. Image-editing applications and automated build tools can generate repeatable derivatives. Browser Network tools show what was actually transferred; Lighthouse and performance traces help identify whether image delivery is a bottleneck on the page.
A smaller image can still leave LCP unchanged if another delay controls when the page becomes visible. Check the actual LCP element rather than assuming the largest file is responsible. A performance score is not an image-quality review. Inspect both, and distinguish laboratory measurements from available real-user data. Compression may reduce transfer work, but it cannot promise a specific ranking gain or compensate for a misleading product image.