Performance
Long task
Long task is a stretch of JavaScript or rendering work on the main thread that lasts more than 50 ms. It blocks input and painting while it runs.
How it is measured
The Long Tasks API reports entries over 50 ms. In DevTools, the Performance panel marks them with a red corner. Total Blocking Time adds up the portion above 50 ms for each task.
A task of 120 ms contributes 70 ms of blocking time. Many small tasks under 50 ms do not count, even when they add up.
Worked example
A product page runs a third-party script that parses for 340 ms starting at 2,200 ms. A tap at 2,300 ms waits 240 ms. Total Blocking Time includes 290 ms from that task. Splitting the work with `setTimeout` chunks of 40 ms removes the blocking contribution.
Another 90 ms task from a carousel contributes 40 ms of TBT.
How it differs
A long task is one blocking stretch. Total blocking time is the sum of their excess over 50 ms during load. The main thread is where they run. One long task hurts one interaction, TBT is a page-level total.
Common errors
Treating 50 ms as a hard rule for UX. Missing tasks caused by third parties. Fixing the average and ignoring the worst. Moving work to a worker without checking messaging cost. Assuming lab traces match slow phones.
In practice
Record a trace on a throttled profile, find tasks above 50 ms, and break the largest ones up or defer them. Check INP after.