Dev.Lib
arrow_backBack to Blogs
LEVEL_099.6June 27, 20261 min read

Long Tasks API

Performance Metrics

Tasks > 50ms block input — PerformanceObserver `longtask` attributes blame to scripts/iframe.

Summary

Tasks > 50ms block input — PerformanceObserver longtask attributes blame to scripts/iframe. Break work, move to worker, use idle callbacks. Long tasks during interaction window hurt INP directly. Main thread is zero-sum at scale.

Code example

new PerformanceObserver((list) => {
  for (const entry of list.getEntries()) {
    console.warn('Long task', entry.duration, 'ms', entry.attribution);
  }
}).observe({ type: 'longtask', buffered: true });

Key points

  • Tasks > 50ms block input — PerformanceObserver longtask attributes blame to scripts/iframe.
  • Break work, move to worker, use idle callbacks.
  • Long tasks during interaction window hurt INP directly.
  • Main thread is zero-sum at scale.

Further reading

Related concepts