Core Web Vitals LCP Ignores Photos in Tabs Opened by Click
On a product page with tabs such as "Description" and "Photo," an element that a user shows by clicking a tab or pressing an arrow key is not counted as the Core Web Vitals LCP (Largest Contentful Paint). In my test environment, I clicked the "Photo" tab about 1 second after the page opened. The photo did not become the LCP. LCP stayed on the description paragraph that was visible first, at 48ms (median of 5 runs). In contrast, with a tab that opens when the mouse hovers over it, and with a tab that a script switches automatically, the photo became the LCP, and the value changed to the time of the switch (about 1000ms). This article is for checking why the LCP element or value collected with web-vitals differs from what you expect on a page with tabs or slides.
The test environment was Ubuntu 24.04, Node.js 22, web-vitals 6.2.3, and Chromium 157 (headless) via Playwright 1.63.0. The page was served from a local server I ran (localhost:8080), with a 412px by 823px viewport. I measured 5 runs for each way of switching. I performed the click, key, and hover actions with Playwright's page.click, page.keyboard, and page.hover. I did not test a real phone with taps, hiding methods other than the hidden attribute (display: none), Lighthouse, real-user data (CrUX, PageSpeed Insights field data), or browsers other than Chrome.
The tab page used for the test
I prepared a page with two tabs, "Description" and "Photo," under a heading. At first the "Description" tab is open, and the "Photo" panel is hidden with the hidden attribute. The photo (an 800×600 PNG) is returned by the server immediately, so loading finishes while it is hidden.
<h1>商品の詳細</h1>
<div role="tablist">
<button role="tab" id="tab-desc" aria-controls="panel-desc" aria-selected="true">説明</button>
<button role="tab" id="tab-photo" aria-controls="panel-photo" aria-selected="false" tabindex="-1">写真</button>
</div>
<div role="tabpanel" id="panel-desc">
<p>この商品の説明が入る段落です。素材や大きさ、使い方などをここに書きます。</p>
</div>
<div role="tabpanel" id="panel-photo" hidden>
<img id="photo" src="photo.png" alt="商品の写真" width="800" height="600">
</div>
When a tab is pressed, the script removes the hidden attribute from the panel of the pressed tab and adds hidden to the other panel. Left and right arrow keys also switch the tabs.
On the page, I collected largest-contentful-paint entries with a PerformanceObserver. I also loaded the web-vitals attribution build and sent its onLCP report (the value and attribution.target, which identifies the element that became the LCP) to the server with navigator.sendBeacon. I switched tabs about 1000ms after the page opened, waited until 3000ms, and then read the entries. After that, I moved to another page (about:blank) and received the web-vitals report from the server. The command output below shows only the first of the 5 runs.
A photo in a hidden panel was not counted, even when already loaded
First, the case with no tab switch. The photo arrived at 14ms (run 1) and was already loaded, but because its panel was hidden, the only entry was the description paragraph. LCP was the paragraph's value (median of 5 runs, 48ms).
$ node measure.cjs none 5
none run1: 切り替えた時刻=— 届いた入力=mouseover,mousemove 写真のタブ=非表示 写真の読み込み=済み(届いた時刻=14ms)
LCPのエントリ: p(48ms,load=0ms,size=17112)
web-vitals の報告: LCP=48 target=#panel-desc>p 報告の時刻=3013ms
For comparison, I also measured a page where the "Photo" tab was open from the start. Here the photo became the LCP, with a median of 52ms over 5 runs. The photo's size (the area visible on screen) was 108300, much larger than the paragraph's 17112.
$ node measure.cjs open-photo 5
open-photo run1: 切り替えた時刻=— 届いた入力=mouseover 写真のタブ=表示 写真の読み込み=済み(届いた時刻=19ms)
LCPのエントリ: #photo(48ms,load=22ms,size=108300)
web-vitals の報告: LCP=48 target=#photo 報告の時刻=3019ms
The mouseover and mousemove listed under "received input" arrived even when I did nothing. As shown later, moving the mouse alone does not stop recording.
A photo in a tab opened by click or arrow key was not counted
At about 1000ms, I clicked the "Photo" tab with Playwright. The photo tab opened and appeared on screen, but in all 5 runs no photo entry arrived, and LCP stayed on the description paragraph (median 48ms).
$ node measure.cjs click 5
click run1: 切り替えた時刻=1017ms 届いた入力=mouseover,mousemove,pointerdown,mousedown,focusin,click 写真のタブ=表示 写真の読み込み=済み(届いた時刻=16ms)
LCPのエントリ: p(52ms,load=0ms,size=17112)
web-vitals の報告: LCP=52 target=#panel-desc>p 報告の時刻=1069ms
The same happened when I focused the "Description" tab and switched with the right arrow key. In all 5 runs the photo was not counted, and LCP was the paragraph's value (median 44ms).
$ node measure.cjs keyboard 5
keyboard run1: 切り替えた時刻=1004ms 届いた入力=mouseover,focusin,keydown 写真のタブ=表示 写真の読み込み=済み(届いた時刻=18ms)
LCPのエントリ: p(56ms,load=0ms,size=17112)
web-vitals の報告: LCP=56 target=#panel-desc>p 報告の時刻=1010ms
The web.dev LCP article says that once the user interacts with the page (taps, scrolling, key presses), the browser stops emitting new LCP entries. The article's example is a tap, but in this test recording also stopped with a mouse click. Because pressing a tab stopped recording, a photo displayed as a result of that press was not counted as the LCP, even though it was much larger than the paragraph.
The times at which web-vitals reported the LCP were also right after the interaction: 1056ms to 1078ms for clicks and 1006ms to 1018ms for keys. In the web-vitals 6.2.3 source code (src/onLCP.ts), when a keydown, click, or visibilitychange event arrives, the processing that finalizes the LCP (finalizeLCP) runs.
With a tab that opens on hover, the photo became the LCP
I changed the tab so that it switches just by hovering, and at about 1000ms I hovered the mouse over the "Photo" tab. The only inputs received were mouseover and mousemove, with no click. In all 5 runs the photo entry arrived, and LCP became the photo's value (median 1072ms).
$ node measure.cjs hover 5
hover run1: 切り替えた時刻=1004ms 届いた入力=mouseover,mousemove 写真のタブ=表示 写真の読み込み=済み(届いた時刻=16ms)
LCPのエントリ: p(56ms,load=0ms,size=17112) #photo(1080ms,load=1070ms,size=108300)
web-vitals の報告: LCP=1080 target=#photo 報告の時刻=3016ms
Moving the mouse is not among the "interactions" listed in the web.dev article (taps, scrolling, key presses), so recording did not stop. Even for the same tab, the LCP element and value differ depending on whether it opens by click or by hovering.
A tab switched by a script also made the photo the LCP
I made the page's script open the "Photo" tab automatically at 1000ms, like a slide that changes after a set time. In all 5 runs the photo entry arrived, and LCP was the photo's value (median 1012ms).
$ node measure.cjs auto 5
auto run1: 切り替えた時刻=1000ms(ページのスクリプト) 届いた入力=mouseover 写真のタブ=表示 写真の読み込み=済み(届いた時刻=14ms)
LCPのエントリ: p(40ms,load=0ms,size=17112) #photo(1012ms,load=1004ms,size=108300)
web-vitals の報告: LCP=1012 target=#photo 報告の時刻=3016ms
The result was the same when the script called click() on the tab button. The click event arrived, but because it was not a user action (isTrusted is false), recording did not stop, and LCP became the photo's value (median 1020ms). In the web-vitals source code too, the processing that finalizes LCP runs only for events where isTrusted is true.
The LCP value was not the time the photo arrived (about 14ms) but the time the tab opened and the photo appeared on screen. On this test page, the mere presence of an automatically switching tab moved LCP from about 50ms to about 1000ms.

Whether an element in a tab is counted as the LCP depends on what opened the tab. Elements in a tab opened by a click or an arrow key are not counted, and LCP is decided by the element that was visible before the click or key press. Elements in a tab opened just by hovering, or opened by a script (including when the script calls click()), are counted, and the LCP value becomes the time the tab opened.





