git404hub

what is queue-microtask fr?

feross/queue-microtask — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2023-11-30

189JavaScriptAudience · developerComplexity · 1/5DormantSetup · easy

tl;dr

A tiny JavaScript package that safely schedules code to run right after the current task finishes, using the native queueMicrotask when available and falling back to Promise-based code otherwise.

vibe map

mindmap
  root((queue-microtask))
    What it does
      Schedule code to run soon
      Cross-environment safety
      Zero dependencies
    Tech stack
      JavaScript
      queueMicrotask
      Promise fallback
    Use cases
      Defer batch updates
      Small bundle libraries
      Cross-platform code
    Audience
      JS library authors
      Web developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

what do people make with this?

VIBE 1

Defer a small piece of code to run right after the current task without using slower setTimeout delays.

VIBE 2

Add microtask scheduling to a library that must run consistently across old and new Node.js versions and browsers.

VIBE 3

Keep bundle size minimal in a cross-platform JS library while still supporting environments lacking native queueMicrotask.

VIBE 4

Flush a batch of pending updates immediately after the current synchronous code finishes.

what's the stack?

JavaScript

how it stacks up fr

feross/queue-microtaskgaearon/react-transform-catch-errorsjianshuo/ccglass
Stars189183181
LanguageJavaScriptJavaScriptJavaScript
Last pushed2023-11-302016-04-18
MaintenanceDormantDormant
Setup difficultyeasyeasyeasy
Complexity1/52/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

how do i run it?

Difficulty · easy time til it works · 5min
No license information was mentioned in the explanation.

in plain english

When you write JavaScript, sometimes you need to schedule a small piece of code to run "very soon", not immediately, but right after the current task finishes, before the browser or server moves on to other work. The modern standard way to do this is a built-in function called queueMicrotask. The queue-microtask package lets developers use this function safely across all modern JavaScript environments, even older versions of Node.js and browsers that don't support it natively yet. Under the hood, if the JavaScript engine already supports queueMicrotask, the package just uses it directly. If it doesn't, the package falls back to using Promise.resolve().then(fn), which achieves the same effect with the same performance. The entire implementation is under ten lines of code with zero dependencies, so it adds almost no weight to your project. This package is for developers building JavaScript applications who want to keep their bundle size as small as possible while still supporting a wide range of environments. For example, if you're building a library that runs in both the browser and Node.js and you need to defer a quick task, like flushing a batch of updates, without the heavy delays of setTimeout, this package handles the inconsistency across platforms for you. If you only need to support Node 12 and later, you don't need this package at all, you can use the built-in function directly. What stands out about this project is its extreme minimalism and the deliberate tradeoff it makes. Other libraries that solve similar problems exist and support very old browsers, but they come with extra code and larger file sizes. This package intentionally skips support for ancient environments lacking Promise support, choosing instead to stay as tiny as possible while delivering optimal performance for the vast majority of users on modern engines.

prompts (copy fr)

prompt 1
Explain how queue-microtask works under the hood and why it falls back to Promise.resolve().then() in older environments.
prompt 2
Show me how to use queue-microtask to defer a batch-update function so it runs right after the current call stack finishes.
prompt 3
I'm building a small JS library and want to keep bundle size minimal, should I use queue-microtask or the native queueMicrotask directly?
prompt 4
What's the difference between using queue-microtask and setTimeout(fn, 0) for scheduling deferred work in JavaScript?

Frequently asked questions

what is queue-microtask fr?

A tiny JavaScript package that safely schedules code to run right after the current task finishes, using the native queueMicrotask when available and falling back to Promise-based code otherwise.

What language is queue-microtask written in?

Mainly JavaScript. The stack also includes JavaScript.

Is queue-microtask actively maintained?

Dormant — no commits in 2+ years (last push 2023-11-30).

What license does queue-microtask use?

No license information was mentioned in the explanation.

How hard is queue-microtask to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is queue-microtask for?

Mainly developer.

peek the repo → explain another one

This repo across BitVibe Labs

double-check against the repo, no cap.