{"id":41936,"library":"scheduler-polyfill","title":"scheduler-polyfill","description":"Polyfill for the Prioritized Task Scheduling API (window.scheduler), providing scheduler.postTask(), scheduler.yield(), TaskController, and TaskSignal. Version 1.3.0, actively maintained by Google Chrome Labs. Uses setTimeout, MessageChannel, and requestIdleCallback with fallbacks. Suitable for browsers that haven't implemented the native API (Chrome 94+, Firefox 101+, Safari 15.4+). Ships TypeScript types. Good for progressive enhancement in scheduling-intensive web apps.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/GoogleChromeLabs/scheduler-polyfill","tags":["javascript","scheduler","scheduling","postTask","TaskController","TaskSignal","typescript"],"install":[{"cmd":"npm install scheduler-polyfill","lang":"bash","label":"npm"},{"cmd":"yarn add scheduler-polyfill","lang":"bash","label":"yarn"},{"cmd":"pnpm add scheduler-polyfill","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is a polyfill that adds self.scheduler, TaskController, etc. as globals. It exports no named symbols; use a side-effect import. TypeScript types are automatically available after the import.","wrong":"import schedulerPolyfill from 'scheduler-polyfill';","symbol":"scheduler-polyfill (side-effect import)","correct":"import 'scheduler-polyfill';"},{"note":"TaskController is added to the global scope. Named import from the package does not work; it must be accessed as a global after the side-effect import.","wrong":"import { TaskController } from 'scheduler-polyfill';","symbol":"TaskController","correct":"import 'scheduler-polyfill'; const controller = new TaskController('user-blocking');"},{"note":"TaskSignal is not directly constructable; it is obtained from TaskController.signal. It becomes a global after the import.","wrong":"import { TaskSignal } from 'scheduler-polyfill';","symbol":"TaskSignal (via TaskController)","correct":"import 'scheduler-polyfill'; const controller = new TaskController('background'); const signal = controller.signal;"}],"quickstart":{"code":"// Install: npm install scheduler-polyfill\n\nimport 'scheduler-polyfill';\n\nasync function example() {\n  const priority = 'user-blocking';\n  const controller = new TaskController(priority);\n  \n  // Schedule a task with signal\n  const result = await self.scheduler.postTask(\n    () => {\n      console.log('Task running with priority:', priority);\n      return 'done';\n    },\n    { signal: controller.signal, priority }\n  );\n  console.log(result); // \"done\"\n}\n\nexample();","lang":"typescript","description":"Shows how to side-effect import the polyfill, create a TaskController, and schedule a postTask with priority and signal. Works in browsers that don't natively support scheduler."},"warnings":[{"fix":"None; this is a known limitation. Do not rely on inherited priorities for yield().","message":"The polyfill does not support priority or signal inheritance for scheduler.yield(); all continuations are scheduled with 'user-visible' priority.","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"Use feature detection or ensure the polyfill runs only in modern environments where requestIdleCallback is available.","message":"In browsers that do not support requestIdleCallback, 'background' tasks will not have low event loop priority and may run in arbitrary order.","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"For strict priority ordering, rely on native scheduler rather than the polyfill.","message":"user-blocking and user-visible tasks share the same event loop priority (setTimeout-like); they are not strictly prioritized above each other in non-native environments.","severity":"gotcha","affected_versions":"<=1.3.0"},{"fix":"Avoid loading the polyfill in modern browsers that already support scheduler to prevent unintended side effects. Use dynamic import with feature detection.","message":"The polyfill may not accurately reflect native scheduler behavior in environments that already support the API; it will only polyfill if self.scheduler is undefined.","severity":"gotcha","affected_versions":"<=1.3.0"}],"env_vars":null,"search_vec":"'1.3.0':19 '101':46 '15.4':48 '94':44 'activ':20 'api':10,42 'app':61 'browser':35 'chrome':24,43 'enhanc':55 'fallback':32 'firefox':45 'good':52 'googl':23 'haven':37 'implement':39 'intens':59 'javascript':62 'lab':25 'maintain':21 'messagechannel':28 'nativ':41 'polyfil':3,4 'posttask':65 'priorit':7 'progress':54 'provid':12 'requestidlecallback':30 'safari':47 'schedul':2,9,58,63,64 'scheduler-polyfil':1 'scheduler.posttask':13 'scheduler.yield':14 'scheduling-intens':57 'settimeout':27 'ship':49 'suitabl':33 'task':8 'taskcontrol':15,66 'tasksign':17,67 'type':51 'typescript':50,68 'use':26 'version':18 'web':60 'window.scheduler':11","created_at":"2026-06-04T18:54:49.643006+00:00","updated_at":"2026-06-04T18:54:49.643006+00:00","problems":[{"fix":"Ensure you have imported 'scheduler-polyfill' as a side-effect before using TaskController.","cause":"Attempting to call TaskController without 'new' because the global is not correctly polyfilled (likely not imported first).","error":"TypeError: Failed to construct 'TaskController': Please use the 'new' operator, this DOM object constructor cannot be called as a function."},{"fix":"Add type=\"module\" to your script tag or use a bundler that supports ES modules.","cause":"Using import statement inside a non-module script or incorrectly bundling the polyfill.","error":"Uncaught SyntaxError: import declarations may only appear at top level of a module"},{"fix":"Check that the polyfill import executes correctly. For non-module scripts, use a <script> tag pointing to the standalone bundle instead.","cause":"self.scheduler is undefined because the polyfill import failed or the browser does not support modules and the polyfill was not loaded.","error":"Cannot read properties of undefined (reading 'postTask')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/GoogleChromeLabs/scheduler-polyfill","github":"https://github.com/GoogleChromeLabs/scheduler-polyfill","docs":null,"changelog":null,"pypi":null,"npm":"scheduler-polyfill","openapi_spec":null,"status_page":null,"smithery":null,"categories":[],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}