Skip to the content

Measure how long the main thread makes users wait

lag is a set of monitors for browser apps, for real user monitoring of the main thread. Each monitor measures one signal of main-thread responsiveness, for example blocked time, long tasks or input latency (INP), and records it as an OpenTelemetry metric. The monitors calibrate their probes and discard the samples that are not valid. A Web Worker also measures the main thread from outside.

Quick startOpen the playground

What the monitors measure

Main-thread lag
DriftLag measures how much of each 100 ms window other tasks block the main thread, with a timer baseline that it calibrates. DriftLag
Long tasks and Long Animation Frames
The monitor records each frame of 50 ms or more, its blocking duration and, in Chromium, the scripts that caused it. Long Animation Frames
INP and the Web Vitals
The page-view vitals give INP, CLS, LCP, FCP and TTFB for each page view, with the rules of web-vitals. Page-view vitals
Hangs, seen from a Web Worker
A worker measures main-thread blocks while they occur, and reports the hangs that a page did not survive. Worker lag
Event loop lag
Blocked time, queueing delay, frame delay and input latency are four different meanings of lag. Each has its monitor. The event loop
OpenTelemetry browser metrics
The monitors record counters and histograms that aggregate correctly over many browsers, for example in Grafana Mimir. Metrics model

What this site holds

lag: Main-thread responsiveness monitoring for browser apps, exported as OpenTelemetry metrics.

To change a page, edit its file in packages/site/content/. The writing style guide tells you how.

An AI model (Claude, from Anthropic) wrote most of the text and the code of this site and of the library, under the direction of the author. The tests and the STE linter examine them. The writing standard gives the reason for this note.