Image Optimization Best Practices
Images are usually the heaviest part of a web page and the easiest to fix, but the advice around them is a long undifferentiated list. In practice the wins are very unevenly distributed: two changes account for most of the improvement, and several popular recommendations are worth almost nothing.
What follows is ordered by impact, with a note on what each one is actually worth.
1. Match dimensions to display size
The largest available win, almost every time, and the one most often skipped.
An image displayed in an 800-pixel column but exported at 4000 pixels wide carries twenty-five times the pixel data it can show. No format change or quality setting recovers that; the bytes are spent on pixels the browser throws away while scaling.
Check the ratio rather than guessing: browser developer tools show an image's rendered size alongside its intrinsic size, and a Lighthouse audit lists oversized images with the saving in kilobytes. Working out the right numbers covers the per-slot dimensions and how much to allow for high-density screens.
Worth: frequently 50–90% of an oversized image's bytes.
2. Use a modern format
Free in visual terms — you are changing the encoder, not the picture. Google's figures put WebP at 25–34% smaller than comparable JPEG at equivalent SSIM quality and 26% smaller than PNG losslessly, and every current browser reads it.
The rules that cover nearly everything:
- Photographs: WebP lossy.
- Screenshots, line art, anything with hard edges: WebP lossless.
- Logos and icons: SVG if you have the vector — sharp at any size, usually smaller than any raster version.
- Never a lossy format for text or line art, whatever the size saving looks like.
AVIF is smaller again where you can serve multiple formats, at a median 50% against JPEG on MDN's figures. The three-way comparison covers when that extra step is worth the friction.
Worth: 25–35% against JPEG, and often far more against a PNG photograph.
3. Compress to about 80%, and stop
Between 100% and 80% quality a photograph loses a lot of bytes and very little appearance. Below about 60% the file barely shrinks further while artifacts become obvious. So 80% is not a timid compromise, it is where the curve flattens.
Practical notes:
- 80% for web photographs, 90–95% for anything that may be printed or edited again.
- Screenshots do not belong in this discussion at all — keep them lossless.
- Verify on detail, not on flat areas. A before/after comparison over hair, foliage or text tells you something; a comparison over a plain wall does not.
- If a file comes back larger than it started, it was already optimised. Keep the original — the compressor does this automatically and marks the file rather than handing you the worse copy.
Worth: substantial on unoptimised exports, near zero on files that have already been through this once.
4. Always set width and height
Not a size saving — a stability one, and it costs nothing.
MDN puts the reason precisely: including height and width "enables the aspect ratio of the image to be calculated by the browser prior to the image being loaded", which reserves the space and "reduc[es] or even prevent[s] a layout shift when the image is downloaded and painted".
Without them the page reflows as each image arrives — text jumps, someone taps the wrong link, and Cumulative Layout Shift suffers. Set the attributes to the image's intrinsic pixel dimensions and let CSS handle the visual size (max-width: 100%; height: auto). Modern browsers use the attributes purely to compute the ratio, so they do not fight your stylesheet.
Worth: nothing in bytes, a great deal in perceived quality and in Core Web Vitals.
5. Lazy-load below the fold — and never above it
loading="lazy" defers an image until it approaches the viewport. MDN describes the two values plainly: eager "loads the image immediately, regardless of whether or not the image is currently within the visual viewport", while lazy "defers loading the image until it reaches a calculated distance from the viewport".
For a page with twenty images and three visible, that is seventeen requests that may never happen. One attribute, no library.
The trap is applying it to everything. Lazy-loading the hero image delays the very element that Largest Contentful Paint is most likely measuring — web.dev lists img elements among the LCP candidates, and the threshold for a good score is 2.5 seconds at the 75th percentile of page loads. Deferring your largest visible image is therefore a direct, self-inflicted regression, and it is a common one because "lazy-load your images" gets repeated without the exception.
The rule: everything below the fold lazy, the hero eager, and if the framework or plugin applies it globally, exempt the hero explicitly.
Worth: large on long pages; negative if you get the hero wrong.
6. Serve the size the device needs
If you control the markup, srcset with a sizes attribute lets the browser pick from candidate widths, so a phone downloads a 600px file and a desktop with a high-density display downloads a 1600px one.
Three widths is plenty for most sites. Frameworks with an image component and image CDNs do this generation for you; a CMS usually creates variants from your upload, which is why giving it a generous source matters.
If you are hand-writing a single img tag, exporting at 2× the display width and moving on is a perfectly reasonable stopping point — the difference between that and a tuned responsive setup is much smaller than the difference between either and an unresized original.
Worth: meaningful on mobile traffic, which is usually most traffic.
7. Strip metadata
A camera JPG can carry tens of kilobytes of EXIF, sometimes an embedded thumbnail and a colour profile as well. On a 3 MB photograph that is noise; on a 40 KB thumbnail it can be a fifth of the file.
The stronger argument is privacy rather than size. EXIF routinely includes the camera body, the exact timestamp and — for phones and GPS-equipped cameras — the coordinates where the photograph was taken. Publishing that with a picture of your house or your child's school is a genuine disclosure, and it happens by accident constantly.
Three of the compressor's four presets strip metadata by default; the dedicated tool shows what a file is carrying before you decide.
Worth: small in bytes, occasionally significant in consequences.
8. The ones that matter less than people think
Being honest about diminishing returns is more useful than a longer list.
Sprite sheets and image concatenation. A real technique under HTTP/1.1, where every request was expensive. Under HTTP/2 and HTTP/3, requests are multiplexed and the benefit is mostly gone — while the cost, a single file that invalidates entirely when one icon changes, remains.
Base64-inlining images in CSS. Saves a request and grows the payload by about a third, blocks rendering while the stylesheet parses, and cannot be cached separately. Occasionally right for a tiny critical icon; usually a downgrade.
Squeezing the last 5%. Once an image is correctly sized, in WebP, at 80%, further tuning yields kilobytes. Time is better spent on the next unoptimised image than on perfecting this one.
Choosing a CDN before fixing your images. A CDN makes delivery faster; it does not make a 4 MB hero appropriate. Fix the asset, then improve the delivery.
The checklist
For a page you are auditing now:
- Every image exported at display width (×2 for high-density where it shows).
- Photographs in WebP, graphics in WebP lossless, logos in SVG.
- Photographs at around 80% quality; graphics lossless.
widthandheighton everyimg.loading="lazy"everywhere below the fold; hero explicitly eager.srcsetwhere you control the markup.- Metadata stripped on anything public.
- Hero under 200 KB, page total under 1 MB.
- Re-run the audit and check the LCP element is what you expected.
Items 1 and 2 will usually deliver most of the improvement. If you only have twenty minutes, do those two across every image on the page rather than all nine on one image.
Image Compressor
Compress JPG, PNG, WebP by quality or target file size. It runs in your browser, so the files never leave your machine, and there is nothing to install or sign up for.
Try the Image CompressorFrequently asked questions
Should I lazy-load all images?
No. Lazy-load everything below the fold and load the hero eagerly. Deferring the largest visible image delays the element Largest Contentful Paint is most likely measuring, so a global lazy-load setting frequently makes the headline metric worse.
How much of a difference does image optimization actually make?
On a page that has never had it, usually the largest single performance improvement available — images are typically most of the page weight. Correct dimensions plus a modern format often cuts total image bytes by 70% or more, with no visible change.
Does image file size affect SEO?
Indirectly, through Core Web Vitals: page experience signals include Largest Contentful Paint, whose good threshold is 2.5 seconds at the 75th percentile, and images are commonly the element being measured. Faster images help that metric. There is no separate ranking bonus for a smaller file.
Is WebP safe to use for all site images now?
For browser display, yes. Keep a JPEG or PNG copy of anything that leaves your site — files sent to clients, print workflows, or third-party upload forms — since support outside browsers is less uniform.
What tool should I use for a whole folder?
Resize the batch to consistent dimensions first, then compress with a single format and quality setting. Both steps handle multiple files at once and run in the browser, so a folder of client photographs is not uploaded anywhere.
The short version
Two practices carry most of the benefit: export at display dimensions and use a modern format. Add an 80% quality setting, width and height attributes, and lazy loading everywhere except the hero, and a page's image weight typically falls by more than half with nothing visibly different. The rest is refinement — and the sprite sheets and inlined Base64 that older advice recommends are mostly obsolete under HTTP/2.
Tools that go with this
Each one is here for a specific reason rather than because it is in the same category.
Image Batch Resizer
Resize multiple images at once online for free
Practice one applied to a whole folder at once, which is where most of the saving is.
Image Format Converter
Convert between JPG, PNG, WebP, AVIF, and HEIC
Practice two: the same picture in a format that costs 30% fewer bytes.
Image Metadata Remover
View and remove EXIF, GPS, and hidden data from images
Strips the non-image bytes, and the location data you probably did not mean to publish.
SVG to PNG Converter
Convert SVG files to high-resolution PNG images
Useful in reverse as a reminder: if you have the vector, the vector is usually the better asset.
Related articles
What Image Size Should You Use on a Website?
Pixel dimensions, file size and DPI are three different things, and only two of them matter on the web. The sizes to use, and why 300 DPI is meaningless here.
JPG vs PNG vs WebP: Which Should You Use?
A decision table plus the published figures: WebP is 25–34% smaller than JPEG and 26% smaller than PNG. When each format still wins, and where AVIF fits.
How to Compress an Image
Compress JPG, PNG or WebP files in your browser: which preset to use, when to set a target size in KB, and the order of operations that saves the most.
How Image Compression Works
Why a photo can lose 80% of its bytes and look identical: what lossy compression discards, how quality settings behave, and why PNG ignores them entirely.
How to Compress Images Without Losing Quality
Truly lossless compression, and visually lossless compression, are different things. Which to use per image type, and where the quality thresholds actually sit.
What Is the Difference Between Lossy and Lossless Compression?
Lossless keeps every pixel; lossy discards what you cannot see. What each one actually promises, why lossless is not "better quality", and which to pick.
Why Your Image Is Still Too Large After Compressing
Six reasons compression did not shrink your file: a PNG that stayed a PNG, dimensions rather than quality, an already-optimised source, or a lying upload limit.
What Is a CR3 File?
CR3 is Canon's raw photo format, introduced in 2018. Here is what is inside one of these files, why most software cannot open them, and what to do with them.
Sources
- The <img> element
MDN Web Docs · Technical documentation · accessed 7 September 2026
Cited for: The lazy and eager loading values, srcset and sizes, and width/height preventing layout shift
- Largest Contentful Paint (LCP)
Google / web.dev · Official documentation · accessed 7 September 2026
Cited for: The 2.5-second good threshold at the 75th percentile, and img elements being LCP candidates — the reason not to lazy-load a hero
- WebP: A new image format for the Web
Google · Official documentation · accessed 7 September 2026
Cited for: The 25–34% saving against JPEG and 26% against PNG that makes format change the second-largest win
About the author
Builder and maintainer, ToolForge
Started ToolForge in May 2026 and has built and maintained it since, writing every tool on the site and the documentation that goes with each one.
Part of
Image Compression & FormatsWhy lossy compression works, which format to use, what image size a web page actually needs, and why a file is still too big after compressing it.
Browse all image tools