Core Web Vitals INP Does Not Count alert() Wait Time
The INP (Interaction to Next Paint) metric in Core Web Vitals does not count the time that an alert() or confirm() dialog stays open. INP only covers the time from the button press until the dialog appears. This explains how to read INP values on pages that show "saved" notifications or delete confirmations with alert() and confirm().
In my test environment, keeping the dialog open for 2 seconds still gave an INP of 0ms when the button was pressed. Adding 300ms of work before the dialog raised INP to 304ms. Adding 300ms of work after the dialog was closed still gave an INP of 0ms.
The test environment was Ubuntu 24.04, Node.js 22, web-vitals 6.2.3, and headless Chromium 157 via Playwright 1.63.0. I served the page from a server I ran locally (localhost:8080), used a 412px-wide viewport, and clicked the buttons with the mouse, measuring each button 5 times. Instead of a person reading and closing the dialog, Playwright waited a set time (usually 2000ms) before closing it. The heavy work was simulated with a loop that kept the main thread busy for the set time. I did not test prompt() or print(), keyboard or tap input, real phones, Chrome 126 and earlier, browsers other than Chrome, or real-user data (CrUX and PageSpeed Insights field data).
- 1. From Chrome 127, INP is split when the dialog appears
- 2. The test page
- 3. Keeping alert or confirm open for 2 seconds still gave an INP of 0ms
- 4. Work before the dialog was counted in INP
- 5. Work after the dialog closed was not counted in INP
- 6. The in-page dialog was measured like a normal interaction
From Chrome 127, INP is split when the dialog appears
INP is a value that represents the slow end of the time from a user interaction (click, tap, or key press) until the next screen update is painted. The web.dev INP article defines 200ms or less as "good" and above 200ms up to 500ms as "needs improvement." In this test, each page load had only one interaction, so that interaction's time was the INP. (With the in-page dialog there were two interactions, and the longer one became the INP.)
The Chrome 127 entry in the Chromium INP changelog describes how dialogs are handled. Before that, the Event Timing API counted the time a synchronous dialog such as alert(), print(), or confirm() stayed open, including the time spent waiting for the user to close it. The reason was that screen updates stopped until the dialog closed.
From Chrome 127, the page is treated as having responded once the dialog appears. Instead of waiting for a screen update, the end of the interaction is set to the moment the dialog is shown. The changelog says that "pages that use JavaScript dialogs may see lower INP."
The test page
I prepared a page with several buttons, each showing a dialog in a different way. The main JavaScript parts are below. busy() is a function that keeps the main thread busy for the given number of milliseconds, $ is a function that gets an element by id, and status is a function that changes the text of a paragraph.
// Run 300ms of work, then show an alert
$('busy-alert').addEventListener('click', () => {
busy(300);
alert('保存しました');
status('alert を閉じました');
});
// Show an alert, then run 300ms of work after it closes
$('alert-busy').addEventListener('click', () => {
alert('保存しました');
busy(300);
status('alert を閉じたあと、300ms の処理をしました');
});
// Run 300ms of work only when confirm returns OK
$('confirm-busy').addEventListener('click', () => {
const ok = confirm('削除しますか?');
if (ok) busy(300);
status(ok ? '削除しました(300ms の処理のあと)' : '取り消しました');
});
I also added a button that shows only alert(), a button that shows only confirm(), and two buttons for comparison. The comparison buttons were one that runs only the 300ms work without any dialog, and one that opens an in-page dialog (a <dialog> element opened with showModal()). In the test code, I wrapped alert() and confirm() in a timing function so the page itself could also measure how long each dialog stayed open.
To measure, I used the attribution build of onINP from web-vitals to receive the INP value. Separately, a PerformanceObserver collected Event Timing API entries (those 16ms or longer), and I recorded each event's time (duration) and how long its listeners ran. I caught each dialog with Playwright's page.on('dialog'), waited 2000ms, and then closed it. Without a handler like this, Playwright closes dialogs automatically. 1.5 seconds after the interaction, the script fired a visibilitychange event, the kind that happens when the tab is switched, to make web-vitals report the INP.
Keeping alert or confirm open for 2 seconds still gave an INP of 0ms
When I pressed the button that shows only alert(), the INP was 0ms in all 5 runs. Measured on the page, the dialog stayed open for 2003ms to 2006ms. The button that shows only confirm() was the same, with an INP of 0ms in all 5 runs.
$ node measure.cjs alert 5
alert run1: dialog=alert「保存しました」 ページで測ったダイアログの時間=2006ms interactionCount=1 status="alert を閉じました"
INP=0 good target=#alert inputDelay=1 processingDuration=0 presentationDelay=0 INPの操作のイベント=pointerdown
events(16ms以上): なし
According to MDN's PerformanceEventTiming documentation, the duration in the Event Timing API is rounded to 8ms steps. In this test, the time from the press until the alert appeared was short, so INP came out as 0. No event took 16ms or longer in the Event Timing API records. The click listener ran for more than 2 seconds, but the click record was under 16ms.
Work before the dialog was counted in INP
When I added 300ms of work before alert(), INP was 304ms in all 5 runs, and the rating was needs-improvement. The button that ran only the 300ms work without a dialog also gave 304ms, the same value.
$ node measure.cjs busy-alert 5
busy-alert run1: dialog=alert「保存しました」 ページで測ったダイアログの時間=2006ms interactionCount=1 status="alert を閉じました"
INP=304 needs-improvement target=#busy-alert inputDelay=0 processingDuration=304 presentationDelay=0 INPの操作のイベント=pointerdown,pointerdown
events(16ms以上): …(途中を省略)… click(duration=304,interactionId=あり,wait=1,run=2307)
run is the time (in ms) from when the event's listeners start running until they finish. The click listeners ran for 2307ms. That is the 300ms of work plus about 2 seconds the dialog was open. Even so, the click
duration was 304ms, which ended at the moment the dialog appeared.

I changed the time the dialog stayed open to 500ms and then to 5000ms. INP was 304ms in all 5 runs both times. The listener run times were 804ms to 805ms and 5305ms to 5306ms.
Work after the dialog closed was not counted in INP
For the button that runs 300ms of work after alert() closes, INP was 0ms in all 5 runs. The work did run, and the paragraph showed a status message saying that the alert was closed and then 300ms of work was done (the message text is in Japanese). The Event Timing API had no records of 16ms or longer either.
The button that runs 300ms of work after the user picks OK in confirm() also gave 0ms in all 5 runs. When the user picked Cancel, it was also 0ms in all 5 runs.
In other words, no matter how heavy the work after a dialog closes, it does not show up in the INP value. In this test, the 300ms after the dialog closed was also work that kept the main thread busy. A good INP value does not tell you that the behavior after the dialog is fast, so you need to check that separately.
The in-page dialog was measured like a normal interaction
For comparison, I also measured a button that opens a <dialog> element with showModal(). Two seconds after it opened, I pressed the "OK" button inside the dialog to close it. INP was 8ms to 16ms (median 16ms).
$ node measure.cjs modal 5
modal run1: dialog=なし ページで測ったダイアログの時間=-ms interactionCount=2 status="ダイアログを閉じました"
INP=16 good target=#modal inputDelay=0 processingDuration=7 presentationDelay=9 INPの操作のイベント=pointerdown,pointerdown
A <dialog> element is part of the page, so the button that opens it and the "OK" button each counted as one interaction (interactionCount=2). Each one is measured up to the end of its listener work and the screen update. Unlike alert(), there was no waiting time while the dialog was open.

When you want to lower INP, look at the work that runs before the dialog appears. In this test, the 300ms before alert() became the 304ms INP as is. If there is heavy work before a dialog, making that work lighter, or showing the dialog first and doing the work later, can shorten the time that counts toward INP. However, work moved to after the dialog closes does not show up in INP, so the slowness has not gone away.





