Notes

Find what makes a page interaction slow

Use Event Timing to separate input delay, handler work and presentation delay, then correlate slow interactions with long animation frames and a DevTools trace.

Record the interaction in DevTools, then separate the wait before handlers, the time running handlers, and the delay until the next paint. A short click handler can still feel slow when earlier work blocks the main thread or its DOM changes trigger expensive layout. Event Timing helps locate the interval; a trace explains the work inside it.

Instrument the page

Paste this into a blank HTML file and open it in a browser. Click both buttons, then inspect the console. Tested in local Chromium; feature checks let the demo run when an observer type or scheduling API is unavailable.

<!doctype html>
<title>Interaction timing demo</title>
<button id="slow">Block</button>
<button id="chunked">Yield between chunks</button>
<output id="status"></output>
<script>
const supported = PerformanceObserver.supportedEntryTypes;
if (supported.includes('event')) {
  new PerformanceObserver(list => {
    for (const e of list.getEntries()) {
      if (!e.interactionId) continue;
      console.log('interaction', {
        id: e.interactionId, event: e.name, total: e.duration,
        inputDelay: e.processingStart - e.startTime,
        handlers: e.processingEnd - e.processingStart,
        presentation: e.startTime + e.duration - e.processingEnd,
      });
    }
  }).observe({ type: 'event', buffered: true, durationThreshold: 16 });
}
if (supported.includes('long-animation-frame')) {
  new PerformanceObserver(list => {
    for (const f of list.getEntries()) {
      console.log('LoAF', f.startTime, f.duration, f.scripts);
    }
  }).observe({ type: 'long-animation-frame', buffered: true });
}
const pause = () => globalThis.scheduler?.yield
  ? globalThis.scheduler.yield()
  : new Promise(resolve => setTimeout(resolve, 0));
function work(ms) {
  const until = performance.now() + ms;
  while (performance.now() < until) {} // Deliberate demo workload.
}
const status = document.querySelector('#status');
document.querySelector('#slow').onclick = () => {
  work(160);
  status.textContent = 'Blocked work finished';
};
document.querySelector('#chunked').onclick = async () => {
  status.textContent = 'Working…';
  for (let i = 0; i < 20; i++) {
    work(8);
    await pause();
  }
  status.textContent = 'Chunked work finished';
};
</script>

Read the evidence

The Event Timing duration includes time through the next rendering update and is rounded for privacy. The arithmetic above gives approximate components, not independent high-resolution measurements. Several events can share one interactionId; one console row is not the page’s INP score. INP aggregates interactions over the visit. Use an established metric implementation such as web-vitals for field reporting rather than taking the maximum printed row.

Long animation frames exceed 50 ms and can include several tasks plus rendering. Correlate their time intervals with slow interaction entries. Script attribution can point at a function or source location, but cross-origin visibility is limited. Missing LoAF entries do not establish that an interaction was fast.

Record and change one cause

In Chrome’s Performance panel, start recording, reproduce one interaction and stop. Select the interaction and inspect the main-thread flame chart. If input delay dominates, inspect the task already running before the event. If processing dominates, inspect handlers and synchronous layout. If presentation dominates, inspect style, layout and paint after the handlers. Repeat with the same workload after changing one cause.

Chunking lets input and rendering run between batches; it does not reduce total CPU work. Move suitable computation to a worker, avoid repeated layout reads after writes, and update feedback before deferred work. await Promise.resolve() does not create the task boundary needed here.

As checked in November 2026, scheduler.yield() is available in Chromium 129+ and Firefox 142+, while Safari support remains absent in the compatibility data linked from the Chrome scheduling guide. Keep the feature check. The timer fallback gives up the main thread but lacks the scheduler’s continuation priority.

See the Event Timing specification, LoAF documentation, and DevTools recording guide. Go deeper into the browser event loop.