How to Compress Images for Websites and Core Web Vitals
Core Web Vitals are times and a layout score, not a file-size grade. On a lot of pages the clock that matters is the hero image: how long it takes to arrive, decode, and paint, and whether it shoves the rest of the page down when it does. You can fix the bytes and the pixels in an image tool. You cannot fix a slow server with a quality slider.
The metric is time, and the image is often the clock
Google's Core Web Vitals are three field measurements, published on web.dev. Largest Contentful Paint (LCP) is good at 2.5 seconds or under, needs improvement up to 4 seconds, and is poor after that. Interaction to Next Paint (INP) is good at 200 milliseconds or under, needs improvement up to 500 milliseconds, and replaced First Input Delay in March 2024. Cumulative Layout Shift (CLS) is good at 0.1 or under and poor above 0.25. None of them is a file-size score. A 40 KB image on a slow server can still miss LCP, and a 200 KB image on a fast host can pass. Bytes are the part of LCP you can fix in an image tool.
On a typical article or product page the LCP element is the hero image or the product photo. LCP time for that image is roughly: time to first byte, plus the download, plus decode, plus paint. Compression changes the download and, if you also shrink the pixel dimensions, the decode. It does not fix a 1.8 second server response. If the page is slow before any image starts, minify and defer JavaScript and CSS first. That job is separate and is covered in Minifying JavaScript and CSS.
A useful working target, not a Google limit: the mobile hero, at the pixel size the phone actually displays, under about 150–200 KB. A desktop hero can be larger because the connection is usually faster and the slot is wider. Measure the result in Chrome DevTools (Lighthouse, or the Network row for that image) rather than trusting a universal kilobyte chart. The format choice itself is in JPEG, PNG, WebP, and AVIF.
Size the pixels to the slot, then encode
A phone column that is 390 CSS pixels wide does not need a 6000-pixel photo. At a device pixel ratio of 2, which is a common phone screen, 780 pixels across the image is already sharp. At ratio 3, about 1170. Shipping 6000 pixels makes the browser download a file an order of magnitude larger and then decode a bitmap that can be close to 100 MB of RGBA in memory (6000 × 4000 × 4 bytes is 96,000,000 bytes) before it scales the picture down to a slot the size of a postcard.
| Where it sits | CSS width, roughly | Export width at 2× | Notes |
|---|---|---|---|
| Article column on a phone | 360–430 px | 800–900 px | This is the file that dominates mobile LCP. |
| Article column on a laptop | 680–800 px | 1400–1600 px | Do not also send this file to the phone. |
| Full-bleed hero | up to the viewport | 1600–2400 px | Cap it. A 3840 px hero is a desktop luxury. |
| Thumbnail in a grid | 150–320 px | 400–640 px | Lazy-load these. They are not the LCP image. |
The arithmetic behind "halve the edge, quarter the pixels" is in Resizing vs Compressing. Do that resize in Image Studio before you touch the quality slider. A quality of 80 on a 1920-pixel WebP is a different file from quality 80 on a 6000-pixel WebP.
Give the browser a choice of widths
One file cannot be the right size for both slots. Export two or three widths from the same crop (for example 800, 1600, and 2400 on the long side), same format, same slider. Then tell the browser which one to fetch:
<img
src="hero-1600.webp"
srcset="hero-800.webp 800w, hero-1600.webp 1600w, hero-2400.webp 2400w"
sizes="(max-width: 700px) 100vw, 720px"
width="1600"
height="1000"
alt="Stainless pour-over kettle on a walnut counter"
>
srcset lists the files and how many pixels wide each one really is. sizes says how wide the slot will be in CSS pixels. The browser multiplies by the screen density and picks a file. width and height are the intrinsic ratio, not the CSS display size. They let the browser reserve the rectangle before the bytes arrive. Without them, the image pops in and everything below it jumps. That jump is CLS.
If you also have an AVIF from a build pipeline, wrap the same idea in <picture> and put the AVIF source first, then WebP, then a JPEG img. Image Studio will make the WebP and the JPEG. It will not make the AVIF. Do not lazy-load any of these if this image is the LCP element.
What to put on the LCP image, and what to leave off
- Do not set
loading="lazy"on the hero. Lazy loading waits until layout decides the image is near the viewport. For the element that defines LCP, that wait is the bug. Lazy-load images below the fold, product grids, and comment avatars. - Do set
fetchpriority="high"on the hero if it is animgin the HTML. That is a hint, not a guarantee, and it is the right hint. Preload the same URL with<link rel="preload" as="image">only when you are sure the URL matches the file the browser will pick. A preload of the desktop 2400-pixel file on a phone wastes the phone's bandwidth and can make LCP worse. - Put the image in the HTML, not only as a CSS background. A
background-imageis harder for the browser to discover early and harder for you to give width, height, and an alt. Decorative backgrounds can stay in CSS. The LCP photo should be animg. - Write the alt as a description, not as keywords. "Kettle" is enough when the caption already tells the story. A sentence is enough when the photo carries the information. Alt text is not a ranking slot for "compress image online."
- Cache the file. A correct image that is re-downloaded on every visit still costs LCP on the second view. Fingerprint the filename or set a long cache lifetime on the image path. HTML can stay short-lived.
Encode settings that hold up on a page
For a photographic hero, WebP with the slider around 75–82 is the default I would export from the studio. JPEG at the same slider is the fallback file. Screenshots of the product UI stay PNG. The comparison slider in the studio is how you check a face and a sky; Lighthouse will not tell you that the sky broke into blocks, only that the bytes were small.
Two exports from one crop is a normal batch, not a special mode. Drop the photo in once, set the crop, set the width to 800, choose WebP, download, then change the width to 1600 and download again. If you have a folder of product photos, the per-image memory of those settings is described in Batch Compress and Export a ZIP. A ZIP is for your archive. The website wants the individual files, with cacheable URLs, not a ZIP the browser cannot paint.
Quality numbers are not portable across encoders. The studio uses the browser's JPEG and WebP encoders. A "80" in Photoshop's dialog is not the same quantizer. Judge the file you downloaded, in the layout, on a phone-sized window. If you have to squint to see damage at 100% zoom, you are done. If you are zooming to 400% to hunt for it, you are optimizing a file nobody will see that way.
A checklist before you call the page done
- Identify the LCP element in Lighthouse or in the Performance panel. Confirm it is the image you think it is. A cookie banner or a web font can steal LCP from the hero.
- Resize that image to the 2× slot width. Export WebP, and a JPEG fallback if you need one.
- Set
widthandheightto the file's pixel dimensions so the ratio is reserved. Set CSS towidth: 100%; height: auto;inside the column. - Add
srcsetandsizesif you made more than one width. Do not mark the heroloading="lazy". - Reload with the Network panel throttled to Fast 3G or Slow 4G. The hero request should be small, early, and not duplicated by a preload of a different URL.
- Check CLS in the same report. If the score moves when images load, a width or height is missing, or an ad slot above the hero has no reserved height. Ads are a common CLS source and an image compressor will not fix them.
INP is mostly JavaScript. A huge image can still hurt it, because decoding a multi-megapixel bitmap occupies the main thread on some devices. The fix is the same resize, not a lower quality on a giant file. If INP is poor and the images are already small, look at the script, not the JPEG.
Frequently Asked Questions
What LCP time counts as good?
Google's documentation calls Largest Contentful Paint good at 2.5 seconds or under, needs-improvement up to 4 seconds, and poor after that. Interaction to Next Paint is good at 200 milliseconds or under. Cumulative Layout Shift is good at 0.1 or under.
Should I lazy-load every image?
Lazy-load images below the fold. Do not set loading=lazy on the image that is the LCP element. That delay is time added to the metric you are trying to pass.
Does Image Studio generate srcset for me?
No. Export each width yourself, at the same crop and slider, and write the srcset and sizes attributes in the page. The studio names the download with the pixel width so you can tell the files apart.
Will a smaller JPEG fix a poor INP score?
Only if the main thread is busy decoding a huge bitmap. INP is mostly JavaScript. Minify and reduce script work for that metric, and resize images so decode stays cheap.
Resize the hero before you encode it
Set the pixel width, then the format. The comparison slider is there so you can see the sky before you ship it.
Open Image Studio