Reason about slow tasks and measurement budgets
Quick answer
A responsiveness budget is a target, not a runtime guarantee. Long uninterrupted main-thread work can delay input and rendering. Use measurements to identify costly work instead of assuming one slow callback explains every problem.
How it works
Legacy Long Tasks instrumentation reports tasks of at least 50 ms when the browser exposes the longtask entry type. The W3C Long Tasks document is marked discontinued in its October 2026 draft; existing implementations can still expose it. Feature-detect, then observe supported entries; also inspect profiler traces and other available metrics. A short task is not proof a page is responsive. Frame intervals vary with display refresh and scheduling; 16.7 ms is only the approximate interval at 60 Hz, not a universal JavaScript allowance. The examples check capability-query shape and synthetic duration classification, not actual long-task delivery.
Local examples
Run in a fresh browser document with local synthetic data. Actual ByteMind editor support is unverified.
(async () => {const types=PerformanceObserver.supportedEntryTypes;console.log(Array.isArray(types),typeof types.includes("longtask"));})()Expected console output:
true booleanThis probes the shape of feature detection, not long-task delivery.
Run in a fresh browser document with local synthetic data. Actual ByteMind editor support is unverified.
(async () => {const durations=[12,49,50,80];console.log(JSON.stringify(durations.filter(ms=>ms>=50)));})()Expected console output:
[50,80]The inclusive threshold selects 50 as well as 80.
Common mistakes
Do not generate unbounded busy loops to test responsiveness or treat a 50 ms cutoff as a complete user-experience metric.
Practice
Compare measured phases with a chosen budget, inspect a browser profiler trace, and explain what a threshold fails to capture.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Reason about slow tasks and measurement budgets — Knowledge Check
Apply the concept and reason about local example output.
What does a 50 ms long-task threshold establish by itself?
Why avoid assuming a universal 16.7 ms script budget?
Does presence of longtask in supportedEntryTypes prove a long task has occurred?
What is the exact console output in Reason about slow tasks and measurement budgets example 1?
(async () => {const types=PerformanceObserver.supportedEntryTypes;console.log(Array.isArray(types),typeof types.includes("longtask"));})()What is the exact console output in Reason about slow tasks and measurement budgets example 2?
(async () => {const durations=[12,49,50,80];console.log(JSON.stringify(durations.filter(ms=>ms>=50)));})()