10 Essential Image Optimization Tips for Web Developers
Practical, up-to-date techniques to shrink image payloads without hurting quality — formats, responsive sizing, lazy loading, LCP priority — so your pages load faster and pass Core Web Vitals.
Images are usually the largest part of a page’s weight. Across the web they account for roughly 63% of total bytes on an average page, and on mobile around 73% of pages use an image as their Largest Contentful Paint element. That makes images the single best place to look for performance wins.
Here are ten changes you can make today, ordered roughly by impact.
1. Start with the right format
Use WebP as your default for photographs and complex graphics, add AVIF in front of it for the assets you encode once, use SVG for logos and icons, and reserve PNG for cases where you genuinely need lossless output.
Choosing the format first avoids re-encoding later. For a deeper decision table, see WebP vs JPEG vs PNG.
2. Compress with intent
Most source images exported from design tools are far heavier than they need to be. Run them through a converter at a quality setting between 75 and 85 and compare: on most photos the difference is invisible while the file drops by a third or more.
Two things to watch:
- Already-compressed sources. Re-compressing a JPEG that was already optimised can make a WebP slightly larger. Always compare the output size to the input.
- Sharp content. Screenshots, diagrams and text need a higher quality setting or lossless mode, because artefacts show up much sooner on flat colours and edges.
3. Resize before you upload
Serving a 4000 pixel wide photo into a 400 pixel slot wastes bandwidth and delays rendering. Export at the largest size you actually display, then use srcset for the smaller breakpoints.
4. Use srcset and sizes
<img
src="hero-800.webp"
srcset="hero-400.webp 400w, hero-800.webp 800w, hero-1600.webp 1600w"
sizes="(max-width: 720px) 100vw, 800px"
alt="Dashboard preview"
width="800"
height="500"
/>
The browser then downloads the smallest file that still looks sharp on the current screen. Combine this with <picture> when you want format negotiation as well as size negotiation.
5. Always set width and height
Missing dimensions cause layout shifts while images load, which shows up directly in your Cumulative Layout Shift score. With modern CSS you can pair width/height attributes with height: auto and keep the aspect ratio intact.
The target for CLS is a score below 0.1.
6. Lazy load below the fold — but prioritise your LCP image
loading="lazy" defers off-screen images until the user scrolls near them. Do not apply it to the hero image, since that delays your Largest Contentful Paint.
Instead, give the LCP image the opposite treatment:
<img src="hero.webp" alt="Hero" width="1200" height="600"
fetchpriority="high" decoding="async" />
You can also preload it from the document head if it is discovered late. Everything else below the fold can load lazily.
7. Use a CDN for delivery
A CDN serves images from a point of presence close to the visitor and can handle format negotiation on the fly, so you do not have to maintain multiple exports by hand. Many CDNs also resize on demand, which removes the temptation to ship a single oversized source.
8. Set long cache lifetimes
Image filenames rarely change. Give them a far-future Cache-Control header, or rely on hashed filenames, so returning visitors download nothing at all. Pair this with a CDN and the second page view becomes almost free.
9. Strip metadata
Camera EXIF data can add tens of kilobytes per file and often includes privacy-sensitive GPS coordinates. Most converters — including IMG2WEBP — drop it during conversion. Check that your pipeline does the same; it is free weight to remove.
10. Measure the result
Run your pages through Lighthouse or WebPageTest before and after, and watch the transferred bytes per image. The Core Web Vitals targets worth tracking are:
| Metric | Good | Needs work |
|---|---|---|
| Largest Contentful Paint (LCP) | ≤ 2.5 s | 2.5-4.0 s |
| Interaction to Next Paint (INP) | ≤ 200 ms | 200-500 ms |
| Cumulative Layout Shift (CLS) | ≤ 0.1 | 0.1-0.25 |
Optimizing without measuring tends to produce work that does not move the metrics that matter.
Putting it together
None of these steps is complicated on its own. The habit that pays off is treating every image as a build artefact: pick the format, resize it, compress it, set its dimensions explicitly and let the browser download only what it needs.
If you only do three things this week, do these: convert your images to WebP, add width/height to every <img>, and take loading="lazy" off your hero image.
Frequently asked questions
How much can image optimization actually help?
On image-heavy pages it is usually the largest single win available. Typical reports show 50-80% reductions in image payload after switching formats and resizing, which translates directly into faster LCP and less bandwidth. For how to process a whole library at once, see our batch conversion guide.
What is a good image file size?
There is no universal number, but as a rule of thumb aim for under 200 KB for most content images and under 100 KB for above-the-fold imagery on mobile. What matters more is that the file is the right resolution for its slot.
Should I use WebP or AVIF for optimization?
Use both if you can. Serve AVIF first, fall back to WebP, and keep the original as the final fallback. AVIF is smaller but slower to encode and slightly less widely supported. Start with WebP from JPG or PNG sources if you want the simplest possible setup.
Does image optimization help SEO?
Indirectly but reliably. Smaller images improve Core Web Vitals, especially LCP and CLS, which feed into Google’s page experience signals. Faster pages also reduce bounce rates, which helps every other metric you care about.