Compress

Compress JPGCompress PNGCompress WebPCompress AVIFCompress to 100 KBCompress to 200 KBCompress to 500 KB

Convert

Convert to JPGConvert to PNGConvert to WebPConvert to AVIFWebP to JPGPNG to JPGJPG to PNGWebP to PNG

Image tools

Crop ImageResize ImageImage to PDFImage to Base64

More tools

AI Prompt GeneratorColor PickerTime Zone ConverterQR Code GeneratorWord CounterPassword Generator
Web Performance

Image Optimization for Core Web Vitals: Fix LCP and CLS

Images are the most common LCP element and a classic cause of layout shift. Here is how to make them help rather than hurt.

The thresholds

Core Web Vitals are three field metrics. Google defines “good” values and assesses them at the 75th percentile of page loads, separately for mobile and desktop.

MetricMeasuresGoodPoor
Largest Contentful Paint (LCP)Loading: when the largest visible element renders≤ 2.5 s> 4 s
Interaction to Next Paint (INP)Responsiveness across the visit≤ 200 ms> 500 ms
Cumulative Layout Shift (CLS)Unexpected movement of content≤ 0.1> 0.25
Largest Contentful Paint thresholdsLCP of 2.5 seconds or less is good, between 2.5 and 4 seconds needs improvement, and above 4 seconds is poor.Good ≤ 2.5 sNeeds improvementPoor > 4 s0 s2.5 s4 s
LCP thresholds as published by Google (web.dev).

INP replaced First Input Delay as a Core Web Vital in March 2024. Images affect INP much less than LCP and CLS, so this guide focuses on those two. Google describes page experience as one of many signals; relevant, helpful content still comes first.

How images drive LCP

On many pages the largest element in the first screen is an image, such as a hero photo or product shot. web.dev breaks LCP into four parts: time to first byte, resource load delay (how long before the browser starts fetching the image), resource load duration (download time) and element render delay. Compression and format affect the third part. Discovery, priority and lazy-loading affect the second.

Fix 1: Make the LCP image small

Resize to the largest size actually displayed, then compress. A hero image that is 3000 pixels wide when the layout shows it at 1200 wastes most of its bytes. Use the resizer and the compressor, or convert to WebP. Serve different sizes to different screens with srcset and sizes.

Fix 2: Never lazy-load the LCP image

Lazy loading is excellent for images below the fold, but on the hero image it delays the request until layout is known, which hurts LCP. Leave the attribute off for the first visible image:

<img src="/img/hero-1200.webp" width="1200" height="630"
     alt="Descriptive text" fetchpriority="high">

Use loading="lazy" for images further down the page.

Fix 3: Help the browser discover it early

If the hero is set as a CSS background image or inserted by JavaScript, the browser finds it late. Prefer a real img element in the HTML. If that is not possible, a preload hint for the image tells the browser to start earlier. The fetchpriority="high" attribute asks the browser to prioritise the request relative to other images.

Fix 4: Prevent layout shift with dimensions

When an image has no declared size, the browser reserves no space until it downloads, and the text below jumps down. Set width and height attributes (the intrinsic pixel size), or use the CSS aspect-ratio property, so space is reserved up front. Responsive CSS such as max-width: 100%; height: auto; still works with these attributes. The same applies to ads, embeds and web fonts, which also cause shifts.

Fix 5: Reduce what loads at the start

  • Compress and resize all above-the-fold images.
  • Do not load several large images before the main one.
  • Serve from a CDN or close to your visitors if your audience is global.
  • Use caching headers with versioned file names for static images.

How to measure properly

There are two kinds of data. Lab data (Lighthouse, PageSpeed Insights lab section) is a simulated test and is useful for debugging. Field data comes from real visitors, such as the Core Web Vitals report in Google Search Console or the field section of PageSpeed Insights, and is what the thresholds apply to. A lab score of 100 does not guarantee good field results, and a smaller image can fix a real LCP problem even if the lab score barely moves. Change one thing at a time and measure again after real traffic has accumulated.

Checklist

  1. Identify your LCP element in PageSpeed Insights.
  2. Resize and compress it, and use WebP or AVIF.
  3. Remove loading="lazy" from it and add fetchpriority="high".
  4. Add width and height to every image.
  5. Lazy-load the rest.
  6. Re-test on mobile.

For the broader foundations, see the image compression guide, and for WordPress sites, WordPress image settings.

Try it now: Compress JPG

Free, private and runs in your browser. Nothing is uploaded.

Open Compress JPG

Frequently asked questions

Indirectly and directly. Large images slow pages and can hurt Core Web Vitals, which are part of Google’s page experience signals. Images also appear in image search, where descriptive filenames and alt text help.
No. Lazy-load images below the fold, but load the main above-the-fold image normally so LCP is not delayed.
A well-compressed WebP or AVIF is usually smaller than JPEG, which shortens the download. Always check the actual file sizes you serve.
Add width and height attributes (or CSS aspect-ratio) to every image so the browser reserves space before it loads.
Lighthouse is a lab simulation, while Search Console reports real-user data. Differences in devices, networks and cached content can explain the gap.

Sources and further reading

External links open the original source. We cite primary or official documentation for factual claims and re-check them when we update an article. See our editorial policy.

Keep reading