Let Your Browser Take a Breather with a Scheduler.yield()
summary
Claim: scheduler.yield() from the prioritized task scheduling API pauses long JavaScript chunks and resumes them as a prioritized microtask so UI events run first, avoiding setTimeout’s unpredictable delays. Demo shows 200 items × 10ms = a 2s freeze without yielding; using yield keeps buttons responsive and logs process in real time. A simulated banking app with 1,000 × 10ms also freezes until yield is enabled (5% interval), after which the interface stays usable. Polyfill exists; browser support is experimental.
AI-written summary · about
chapters (11)
- 0:00Introduction and Speaker Background
- 1:11Understanding Scheduler Yield
- 2:00JavaScript Task Processing Basics
- 2:42The Problem with Long Tasks
- 5:37Simulating Heavy Computation
- 7:55Demonstrating the Problem
- 11:32Exploring Solutions
- 15:56Introducing Scheduler Yield
- 18:26Prioritized Task Scheduling API
- 21:49Practical Demo: Banking Application
- 27:00Conclusion and Final Thoughts
related talks
27mDon't block the event loop!JavaScript Async for Effortless UX
27mWhen JavaScript takes its coffee break?
37mRuntime Scheduling on the Web
44mLeveraging the Event Loop for Blazing-Fast Apps!
34mJavaScript's Secret Life Between the Ticks
01h 02mWeb Performance Tuning with browser APIs
35mIn the loop
33mA Quest to Guarantee Responsiveness: Scheduling On and Off the Main Thread
