# astoilkov/main-thread-scheduling

Fast and consistently responsive apps using a single function call

Repository: https://github.com/astoilkov/main-thread-scheduling
Canonical: https://ross.abutalabs.com/products/main-thread-scheduling
Language: TypeScript
License: MIT
License Family: permissive
Topics: posttask, worker, background, yield, thread, webworker, defer, scheduling, main-thread, postpone, eventloop, scheduler, isinputpending
Last push: 2025-01-13T12:36:48+00:00

## Health v2 (maintenance only)
Score: 23/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 1, release rhythm 8, longevity 100
- inputs: {"age_days": 2010, "days_push": 597, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1331, forks 33 (observed 2026-08-28T04:04:24.273160+00:00)

## What it is
A TypeScript library for running computationally heavy tasks on the browser main thread without freezing the UI, using a simple yieldOrContinue() API. It schedules work with requestIdleCallback, isInputPending, and a global priority queue to keep apps responsive.

## Use cases
- make a synchronous function non-blocking without web workers
- prevent UI freezes during heavy computation
- improve INP and Core Web Vitals scores
- run background tasks without spinning up fans
- prioritize rendering important elements first
- run multiple background tasks without degrading performance

## When to choose
- you want to avoid the complexity of Web Workers while keeping the UI responsive
- you need fine-grained yielding inside long-running main-thread tasks
- you want a tiny, production-tested scheduling library with a simple API

## When to avoid
- your task is purely CPU-bound and works well in a Web Worker with no DOM access needs
- you need true parallelism across multiple cores
- you are working outside a browser environment where scheduling APIs are unavailable

## Facets
- artifact type: library
- maturity: active
- function: concurrency, scheduling, developer-tools
- domain: web-development, frontend, performance
- platform: browser
- tags: main-thread, event-loop, yield, isinputpending, inp, web-vitals, typescript, non-blocking, web-server, nodejs

## Member repositories
- astoilkov/main-thread-scheduling (main) score 23

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:24.273160+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T04:45:15.147651+00:00, confidence not recorded.
  - readme: https://github.com/astoilkov/main-thread-scheduling (fetched 2026-08-28T04:04:24.273160+00:00, sha 0149486b007b)
  - registry_npm: https://registry.npmjs.org/main-thread-scheduling (fetched 2026-08-29T12:04:34.148775+00:00, sha aa85c4092d6a)
- Data as of 2026-08-30T08:39:29.467469+00:00.
