# @wordpress/priority-queue

> Generic browser priority queue.

Latest version **3.55.0** (published 2026-09-10) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/priority-queue
pnpm add @wordpress/priority-queue
yarn add @wordpress/priority-queue
bun add @wordpress/priority-queue
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.55.0 |
| Published | 2026-09-10 |
| First published | 2019-03-06 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 1 |
| Unpacked size | 79.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11748 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, gutenberg, browser, async |

## Links

- npm: https://www.npmjs.com/package/@wordpress/priority-queue
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/priority-queue/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/priority-queue

## Dependencies (1)

- [requestidlecallback](https://npm.io/package/requestidlecallback.md) ^0.3.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.55.0 (latest) — 2026-09-10
- 3.54.1-next.v.202609031004.0 (next) — 2026-09-03
- 3.40.1 (wp-7.0) — 2026-06-30
- 3.33.1 (wp-6.9) — 2025-10-28
- 3.19.1 (wp-6.8) — 2025-03-10
- 3.8.1 (wp-6.7) — 2024-09-19
- 3.0.1 (wp-6.6) — 2024-06-11
- 2.51.1 (wp-6.5) — 2024-02-20
- 2.42.13 (wp-6.4) — 2023-11-13
- 2.35.2 (wp-6.3) — 2023-10-12
- 2.26.2 (wp-6.2) — 2023-10-12
- 2.17.2 (wp-6.1) — 2022-09-20
- 2.6.1 (wp-6.0) — 2022-04-19
- 2.2.3 (wp-5.9) — 2021-11-15
- 2.1.2 (wp-5.8) — 2021-09-01
- … 221 more at https://npm.io/package/@wordpress/priority-queue/versions

## README

# Priority Queue

This module allows you to run a queue of callback while on the browser's idle time making sure the higher-priority work is performed first.

## Installation

Install the module

```bash
npm install @wordpress/priority-queue --save
```

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### createQueue

Creates a context-aware queue that only executes the last task of a given context.

_Usage_

```js
import { createQueue } from '@wordpress/priority-queue';

const queue = createQueue();

// Context objects.
const ctx1 = {};
const ctx2 = {};

// For a given context in the queue, only the last callback is executed.
queue.add( ctx1, () => console.log( 'This will be printed first' ) );
queue.add( ctx2, () => console.log( "This won't be printed" ) );
queue.add( ctx2, () => console.log( 'This will be printed second' ) );
```

_Returns_

-   `WPPriorityQueue`: Queue object with `add`, `flush` and `reset` methods.

<!-- END TOKEN(Autogenerated API docs) -->

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

---
_Source: https://npm.io/package/@wordpress/priority-queue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
