日本語

How Much Does Image Format Change LCP in Core Web Vitals?

​​Core Web Vitals​AVIF,JPEG,Lighthouse,Playwright,sharp,web-vitals,WebP

On the pages I tested, when the large image at the top of the page (the hero image) was the LCP element and I switched it from JPEG to WebP or AVIF, LCP dropped by roughly the transfer time saved by the smaller file. If PageSpeed Insights or Lighthouse reports a slow LCP and you are deciding whether to change the image format, these numbers give a rough idea of what to expect. I prepared JPEG, WebP, and AVIF versions of the same image at matched quality, and I report the LCP values measured with Google's web-vitals library as they came out.

Note

The test environment was Ubuntu 24.04 and Node.js 22. The browser was Chrome for Testing 158, bundled with Playwright 1.63.0. I measured LCP with web-vitals 6.2.3, converted images with sharp 0.33.5, and compared image quality with ffmpeg 6.1.1. The pages were served without caching from a small server I ran locally (localhost:8080, HTTP/1.1). The test image was a 1200×800 pattern drawn with ImageMagick, not a real photo. I did not test HTTP/2 or HTTP/3 servers, CDNs, browsers other than Chrome, PageSpeed Insights, real-user data (field data), or results on a live website.

Preparing JPEG, WebP, and AVIF at the same quality

When comparing formats, match the quality before comparing file sizes. The sharp quality number means something different for each format, so the same number does not give the same image quality. I therefore exported the image at several quality settings and computed how closely each result matched the original using the ssim filter in ffmpeg. SSIM is a value that equals 1 for identical images.

console
$ node sweep.mjs '{"jpeg":[60,70,75,80,85,86,87,88,90],"webp":[60,70,75,80,85,90,91],"avif":[35,40,45,50,55,60,65,66]}'
format quality bytes ssim
...
jpeg 87 95969 0.950306
...
webp 90 86470 0.948763
...
avif 65 49881 0.950402

(Other quality rows are omitted.)

I used the following three settings, which give SSIM values close to 0.95. The JPEG was exported with mozjpeg: true in sharp.

Format sharp quality Size SSIM
JPEG 87 95,969 bytes 0.9503
WebP 90 86,470 bytes 0.9488
AVIF 65 49,881 bytes 0.9504

For this image, with JPEG as 100, WebP was about 90 and AVIF was about 52. How much smaller the files get depends on the image, so check this with your own site's images.

The test page contained one image, a heading, and a short sentence. The three pages differed only in the image's file extension and the <title>.

html
<img src="/hero.avif" alt="検証用の大きな画像" width="1200" height="800">
<h1>猫の手日記</h1>
<p>大きな画像の下に、記事の本文が続きます。</p>

Measuring LCP with web-vitals

For measurement I used the onLCP function from Google's web-vitals library. The attribution build of onLCP returns the LCP value along with its breakdown: TTFB, resource load delay, resource load duration, and element render delay.

I opened each page in Playwright with the viewport set to 412×823 at a device pixel ratio of 1.75, matching Lighthouse's mobile settings. Each run used a new browser context with caching disabled. After the page finished loading, I added web-vitals and used reportAllChanges: true to receive a value each time the LCP candidate changed, recording the last value. I prepared three network and CPU conditions and measured each seven times.

  • Slow mobile connection: 562.5ms latency, 1,474.56Kbps download, CPU slowed 4x
  • 10Mbps download: 40ms latency, CPU slowed 4x
  • No throttling: connected directly to localhost on the test machine

The slow mobile values reproduce Lighthouse's mobile setting (Slow 4G) using the DevTools method. For the 10Mbps condition, I used Lighthouse's desktop setting of 40ms RTT and 10Mbps download as DevTools latency and download speed without any adjustment. I slowed the CPU 4x here, while Lighthouse's desktop setting uses 1x. Both sets of values come from the constants Lighthouse uses.

On the slow mobile connection, AVIF saved about 0.23 seconds

The medians of the seven runs were:

Horizontal bar chart comparing LCP by format. On the slow mobile connection, JPEG was 1,684ms, WebP 1,636ms, and AVIF 1,452ms. At 10Mbps download, JPEG was 200ms, WebP 192ms, and AVIF 172ms. The chart labels are in Japanese.
LCP by format (web-vitals, median of 7 runs). The chart labels are in Japanese.
Condition JPEG WebP AVIF
Slow mobile connection 1,684ms 1,636ms 1,452ms
10Mbps download 200ms 192ms 172ms
No throttling (localhost) 32ms 32ms 36ms

On the slow mobile connection, AVIF reduced LCP by 232ms compared with JPEG. WebP reduced it by 48ms. Across the seven runs, the spread for each format stayed within 20ms. At 10Mbps download, AVIF saved 28ms and WebP saved 8ms. On localhost without throttling, I saw no difference between formats.

The LCP breakdown shows where the time went. Here is the first run on the slow mobile connection:

console
$ node measure.cjs 7
chromium 158.0.8127.36

== slow: 遅いモバイル回線(遅延562.5ms・下り1.47Mbps)+CPU 4倍遅く ==
jpg run1: LCP=1680ms element=html>body>img bytes=95969 | TTFB=565 loadDelay=26 loadDuration=1075 renderDelay=14
...
webp run1: LCP=1632ms element=html>body>img bytes=86470 | TTFB=564 loadDelay=24 loadDuration=1024 renderDelay=20
...
avif run1: LCP=1452ms element=html>body>img bytes=49881 | TTFB=564 loadDelay=37 loadDuration=828 renderDelay=23

loadDuration is the time spent fetching the image itself (resource load duration), and renderDelay is the time from when the fetch finished to when the image was drawn on screen (element render delay). The big change was in loadDuration: 1,075ms for JPEG became 828ms for AVIF. TTFB and loadDelay (the wait before the image fetch starts) did not change with format.

The difference between JPEG and AVIF is 46,088 bytes. Sending that over a 1,474.56Kbps download takes about 244ms, which is close to the 232ms LCP difference. Under this condition, the LCP reduction could be roughly estimated as "bytes saved ÷ connection speed". At 10Mbps the same calculation gives about 35ms, and the actual reduction was 28ms.

Decoding AVIF takes only a few milliseconds longer than JPEG

To check whether the format changes the work needed before the image can be drawn, I also measured decode time, excluding the fetch. I fetched the image once on the page and measured the time until img.decode() finished, taking the median of 10 runs.

console
$ node decode.cjs
CPU x1 jpg: decode median=8.0ms (min 7.5, max 8.4, 10回)
CPU x1 webp: decode median=12.1ms (min 9.2, max 13.8, 10回)
CPU x1 avif: decode median=12.2ms (min 11.1, max 13.1, 10回)
CPU x4 jpg: decode median=10.1ms (min 8.8, max 11.6, 10回)
CPU x4 webp: decode median=11.0ms (min 10.4, max 12.7, 10回)
CPU x4 avif: decode median=13.7ms (min 11.2, max 19.1, 10回)

Even with the CPU slowed 4x, decode time barely changed. In the LCP breakdown from the first slow mobile run, AVIF's renderDelay (23ms) was only 9ms longer than JPEG's (14ms). On localhost, loadDuration was 1 to 2ms for every format, so the transfer difference was negligible and LCP showed no difference by format.

How much you save depends on what the image display is waiting for

The web.dev LCP optimization guide includes an example in which the LCP image is hidden until JavaScript finishes loading. It explains that making the image's download faster only moves the time into element render delay, so LCP does not improve. I built two pages that hide the image and show it later, and tested them.

The first page hides the image with visibility: hidden and reveals it at the end of a roughly 250KB script loaded with defer. I measured seven runs each on the slow mobile connection. The medians were 3,020ms for JPEG, 2,976ms for WebP, and 2,788ms for AVIF. AVIF was 232ms faster, the same as on the image-only page.

console
$ node measure.cjs 7 slow,mid hidden-
jpg run1: LCP=3020ms element=#hero bytes=95969 | TTFB=564 loadDelay=30 loadDuration=1588 renderDelay=838
...
avif run1: LCP=2784ms element=#hero bytes=49881 | TTFB=564 loadDelay=27 loadDuration=1092 renderDelay=1101

AVIF's renderDelay got longer, but LCP itself still dropped. I checked three runs of the times when the image and script fetches finished (Resource Timing responseEnd). The image and script started fetching at the same time. The script finished at 2,994ms on the JPEG page and at 2,744 to 2,764ms on the AVIF page. Because the image was smaller, the script arriving at the same time also arrived sooner, and the display moved earlier by that amount. web.dev's guide makes the same point: loading many resources at once causes network contention, which slows each resource's load.

The second page hides the image and reveals it with a 2.5-second timer:

html
<img id="hero" class="hide" src="/hero.avif" alt="検証用の大きな画像" width="1200" height="800">
<h1>猫の手日記</h1>
<p>大きな画像の下に、記事の本文が続きます。</p>
<script>setTimeout(() => document.getElementById('hero').classList.remove('hide'), 2500);</script>

I measured five runs each on the slow mobile connection. The LCP medians were 3,124ms for JPEG, 3,120ms for WebP, and 3,124ms for AVIF, with no difference by format.

console
$ node measure.cjs 5 slow timer- 4000
jpg run1: LCP=3120ms element=#hero bytes=95969 | TTFB=564 loadDelay=23 loadDuration=1078 renderDelay=1455
...
avif run1: LCP=3124ms element=#hero bytes=49881 | TTFB=563 loadDelay=27 loadDuration=831 renderDelay=1703

AVIF's loadDuration was 247ms shorter than JPEG's, but its renderDelay was 248ms longer. As in the web.dev example, the time just moved within the breakdown. On this page, the image fetch finished before the timer fired in every format, so the display time was set entirely by the timer.

Lighthouse flagged the display size, not the format

I ran Lighthouse 13.6.0 three times on each of the three pages, using the default settings (mobile, without --throttling-method).

console
$ npx lighthouse http://localhost:8080/jpg.html --only-categories=performance --output=json --output-path=out/jpg-1.json --chrome-flags="--headless=new --no-sandbox" --quiet
$ node lhsum.cjs out/jpg-1.json "jpg run1"
jpg run1: lighthouse 13.6.0 formFactor=mobile throttlingMethod=simulate score=100 LCP=1351ms (1.4 s)
  image-delivery-insight: score=0 displayValue="Est savings of 60 KiB" metricSavings={"FCP":0,"LCP":300}
    http://localhost:8080/hero.jpg totalBytes=95969 reason: This image file is larger than it needs to be (1200x800) for its displayed dimensions (721x481). Use responsive images to reduce the image download size.

lhsum.cjs is a small script that extracts the LCP value and the "Improve image delivery" audit from the result JSON. The LCP values were:

Format Run 1 Run 2 Run 3
JPEG 1,351ms 1,351ms 1,351ms
WebP 1,202ms 1,351ms 1,352ms
AVIF 1,201ms 1,202ms 1,202ms

By default, Lighthouse does not actually throttle the network. It loads the page at full speed and then estimates how it would have loaded on a slow connection (Lighthouse throttling docs). In these results, LCP was either 1,201 to 1,202ms or 1,351 to 1,352ms. WebP sometimes matched the JPEG value and sometimes the AVIF value. A single default-settings Lighthouse run cannot distinguish differences this small.

The "Improve image delivery" audit appeared for all three formats. The reason was not the format but the size: "This image file is larger than it needs to be (1200×800) for its displayed dimensions (721×481)". At this viewport width, Lighthouse estimated that resizing the image to its display size alone would save about 60KiB even as a JPEG. Before changing the format, check whether you are serving images sized for their display dimensions.

What to check before changing the format

The web.dev Core Web Vitals guide says a "good" LCP is 2.5 seconds or less. These test pages contained only one image, so even on the slow mobile connection, the JPEG version stayed under 2.5 seconds. In this test, the time saved by changing format was roughly the bytes saved divided by the connection speed. Before changing the format, check how much of the LCP breakdown is loadDuration and whether the image display is waiting on something such as a timer or a script. That gives you a sense of how much a format change is likely to help.

To serve JPEG to browsers that do not support AVIF, use <picture> to choose the format. According to the MDN picture element guide, a browser skips a <source> if it does not support the format given in its type. In Chrome for Testing 158, loading the following page fetched only /hero.avif.

html
<picture>
  <source srcset="/hero.avif" type="image/avif">
  <source srcset="/hero.webp" type="image/webp">
  <img src="/hero.jpg" alt="検証用の大きな画像" width="1200" height="800">
</picture>

​Posted by 86