Description
main-thread-scheduling is a JavaScript library for running heavy work on the main thread without freezing the page. The README says it keeps your UI responsive, stops the computer's fans from spinning up, and keeps your Interaction to Next Paint score in the good range. Its main function, yieldOrContinue(strategy), covers most uses, and the library has two more functions for advanced cases. Typical uses include turning a synchronous function into a non-blocking one, rendering important elements first and less urgent ones later, and running a long background task that does not slow the app down over time. Under the hood it uses requestIdleCallback and requestAfterFrame to schedule work. It pauses task execution when the user interacts with the UI, if the browser provides navigator.scheduling.isInputPending(). Tasks share one global queue, are sorted by importance, and tasks with the idle strategy run last. The README shows a demo that searches 10,000 notes of about 200,000 lines of text with instant results.…
Highlights
- Runs heavy work on the main thread without freezing the UI
- yieldOrContinue(strategy) covers most cases
- Tasks sorted by strategy, with idle tasks run last
- Pauses work while the user interacts
- One global queue for background tasks
Ratings & Reviews
No ratings yet
Be the first to rate Main Thread Scheduling.
People also visit

flutter-handling-concurrency
Executes long-running tasks in background isolates to keep the UI responsive
Main Thread Scheduling FAQ
What is main-thread-scheduling for?
Running heavy JavaScript work in small pieces so the page stays responsive.
What is the main function?
yieldOrContinue(strategy). The README says it covers about 90 percent of cases, and the other two functions are for advanced use.
How does it keep input responsive?
It stops running tasks when the user interacts with the UI, if the browser provides navigator.scheduling.isInputPending().
Which browser APIs does it use?
requestIdleCallback and requestAfterFrame for scheduling the work.
Does adding more tasks slow things down?
The README says tasks run one by one from a shared queue, so adding more tasks does not degrade performance in a straight line.
What are the best Main Thread Scheduling alternatives?
Popular alternatives to Main Thread Scheduling include Schedule, Poolifier and Sidequest.js. See all Main Thread Scheduling alternatives






