Image optimization is not about converting everything to one format or making files as small as possible. First, choose images that help readers understand the content. Then choose a format suited to photographs, text, or line drawings, as appropriate. Resize the image based on its display dimensions and the device pixel ratio, then compare image quality and file size after compression. WebP and AVIF may use less bandwidth than JPEG and PNG, but their suitability still depends on the image content, browser support, and actual results.
Decide what the image should communicate before choosing a format
Images should serve the content and readers’ needs: photographs can show what a product looks like, while diagrams can explain processes or data. Do not add an image just because it looks attractive, and do not treat every image as a photograph.
- Photographs: Consider JPEG. Photographs with rich colors and detail are also good candidates for testing lossy compression.
- Images with transparent backgrounds or text: Consider PNG, and check that text and details remain clear.
- Line drawings and charts: SVG is suitable for images without fine photographic detail. It is a text-based vector format that can also be minified and compressed.
Look beyond file extensions when comparing WebP and AVIF
According to web.dev, WebP is widely supported by modern browsers, offers both lossy and lossless compression, and can preserve transparency even with lossy compression. AVIF also supports both compression methods, along with wide color gamut and HDR capabilities. However, web.dev notes that AVIF’s browser support is less extensive than WebP’s.
Both formats may produce smaller files than JPEG or PNG, reducing download times and potentially improving Largest Contentful Paint (LCP). Not every image will benefit to the same degree, though. If you need to accommodate browsers that do not support newer formats, you can provide fallback versions such as JPEG.
Account for both display dimensions and pixel ratio when resizing
An image’s pixel dimensions and file size are different things. For an image displayed in a 500 × 500-pixel area, a 500 × 500-pixel image would suffice, leaving other variables aside. At a device pixel ratio (DPR) of 2, the corresponding dimensions are 1000 × 1000 pixels; at a DPR of 3, they are 1500 × 1500 pixels.
However, web.dev also notes that in most cases, increasing the DPR to 3 does not reveal more detail to the human eye. Rather than always generating the largest version, prepare sizes suited to the display requirements so that different screens receive suitable images.
There is no universal compression setting: inspect the results
Lossless compression preserves image data, while lossy compression discards some image information. Photographs contain rich detail, so compression artifacts are usually less noticeable. Sharp edges, lines, and text require greater care, particularly high-contrast colored text on solid-color backgrounds, where chroma subsampling artifacts may appear.
Use Squoosh or ImageOptim to try different compression levels, comparing image quality and file size for each result rather than always using a fixed quality percentage. After optimization, test the page with PageSpeed Insights or WebPageTest to check whether smaller image files actually improve loading performance.
Image and file format optimization: perspectives from across the web
How can you ensure different browsers receive an image format they support?
You can prepare versions in formats such as WebP, AVIF, and JPEG, including fallbacks, so browsers can select a supported format. If the server determines the format based on the request's Accept header, it should also use the Vary response header so shared caches can recognize that the same URL may return different responses. Avoid adding unlimited format variants, as each version may increase caching and management costs.
Are automatic conversion and optimization suitable for large numbers of images?
When you have many images, consider batch processing or automatic conversion, but assess the costs and hosting workload first. Automated services may not suit every budget. Converting images on your own site and retaining multiple versions may increase storage, backup, and migration burdens, while the conversion process itself also consumes hosting resources. Before choosing an approach, weigh the number of images against your ability to operate and maintain the setup.
Must images always be compressed below a fixed number of KB?
There is no need to treat a single number as a strict limit for every image. Screaming Frog classifies images over 100 KB as large, which is useful for identifying images worth reviewing; another article generally recommends keeping images below 500 KB. These are reference points for different purposes. You should still consider the image's purpose and quality, then check page loading performance.
Besides reducing image quality, how else can you shrink image files?
Check whether EXIF data needs to be retained. Removing this information may further reduce file size without relying solely on lowering image quality. If the photographic metadata is valuable for the intended use, confirm what needs to be preserved before processing. Afterward, use page speed tools to assess how the changes affect actual loading performance rather than looking only at an individual image's file size.
References
- Image performanceweb.dev — Discusses: How can you ensure different browsers receive an image format they support?; Are automatic conversion and optimization suitable for large numbers of images?
- Is 100/100 PageSpeed score enough? The answer is No.www.semrush.com · 2020-07-30T13:00:00Z — Discusses: Are automatic conversion and optimization suitable for large numbers of images?
- 網站速度優化對SEO的影響,從Google Page Speed Insights切入www.awoo.ai · 2019-05-14T03:28:00+00:00 — Discusses: Are automatic conversion and optimization suitable for large numbers of images?
- Image SEO: Optimizing images for search enginesyoast.com · 2026-09-12T12:00:00+00:00 — Discusses: Besides reducing image quality, how else can you shrink image files?
- Mastering SEO Audits: Unlocking Insights with the Screaming Frog SEO Spiderwww.screamingfrog.co.uk · 2023-10-18T10:42:49+00:00 — Discusses: Must images always be compressed below a fixed number of KB?
- Image SEO: Tips for Image Optimizationneilpatel.com · 2024-11-26T20:00:00+00:00 — Discusses: Must images always be compressed below a fixed number of KB?
