← Back to release summary

scheduler.yield()

Category
Performance
Type
New or changed feature
Status
Enabled by default (Chrome 129)
Intent stage
Origin Trial

Summary

Provides a method for yielding control to the browser, which can be used to break up long tasks. Awaiting the promise returned by scheduler.yield() causes the current task to yield, continuing in a new browser task. This can be used to improve responsiveness issues caused by long tasks. Continuations are prioritized to mitigate performance problems of existing alternatives.

Motivation

Long tasks (JavaScript) can lead to poor responsiveness by blocking the main thread from handling inputs or delaying the resulting UI update. Developers can mitigate this by decreasing task lengths, either by doing less work or by breaking up long tasks. Scheduling a continuation using current APIs typically has poor ergonomics because intuitively one wants to pause/resume the current task, not schedule a new task. It can also incur a performance penalty if arbitrary JavaScript runs between yield and continuation. scheduler.yield() is an ergonomic API for breaking up long tasks that mitigates performance issues of existing methods. Developers can await scheduler.yield() to break up long tasks, giving the UA an opportunity to run higher priority work, e.g. input. scheduler.yield() continuations are prioritized over tasks of the same priority or similar task sources, which helps mitigate the performance penalty of yielding.

Standards & signals

Explainers: https://github.com/WICG/scheduling-apis/blob/main/explainers/yield-and-continuation.md https://github.com/WICG/scheduling-apis/blob/main/explainers/prioritized-task-scheduling.md#scheduleryield

View on chromestatus.com