long task
A task that keeps the main thread busy for more than 50 milliseconds, long enough for users to notice lag.
In more detail
During a long task the browser cannot respond to clicks or paint. Breaking work into smaller chunks and yielding in between is the main fix and improves Interaction to Next Paint.
Related terms
- main thread — The first thread a program starts with; in a browser page it also runs JavaScript and handles input, layout and painting.
- scheduler.yield() — A browser API that pauses a long-running async function so the browser can handle input and rendering, then resumes it with high priority.
- Interaction to Next Paint — A Core Web Vital measuring how quickly a page visibly responds to clicks, taps and key presses, taking roughly the worst interaction of the visit.
Taught in
- The Browser Event Loop: Call Stack, Microtasks And Macrotasks — Frontend Architecture & Web Platform
- Core Web Vitals: Measuring And Optimizing LCP, INP, And CLS — Frontend Architecture & Web Platform