Registry / performance / layout-queue

layout-queue

JSON →
library1.0.0jsnpmunverified

layout-queue v1.0.0 is a lightweight JavaScript library that manages sequential execution of layout-affecting actions on window resize, preventing race conditions. Developed by davejtoews, it queues functions and triggers them in order on window load and resize events, with support for custom triggers (e.g., AJAX, iframe load). Alternative to manual resize handlers or debouncing, it ensures predictable execution order. No updates since initial release; stable but low maintenance.

npm install layout-queue
INSTALL
IMPORT
SIG · LAYOUT-QUEUE
L
layout-queue
performancejavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LayoutQueue
import LayoutQueue from 'layout-queue'
const LayoutQueue = require('layout-queue')
Default ES module export; CommonJS require might not work if package does not provide a CJS build.
LayoutQueue
const LayoutQueue = require('layout-queue').default || require('layout-queue')
const LayoutQueue = require('layout-queue') // Only works if package has CJS export
For CommonJS environments, try the incorrect pattern first, but may need .default fallback.
LayoutQueue (browser script tag)
<script src='node_modules/layout-queue/bundle.js'><script> LayoutQueue.add(...)
Bundle approach exposes LayoutQueue globally; no import needed.

Demonstrates importing LayoutQueue, adding a function with arguments, triggering execution, listing, and clearing the queue.

import LayoutQueue from 'layout-queue'; function updateLayout(size) { console.log(`Resized to ${size}px`); // Update elements } LayoutQueue.add(updateLayout, [window.innerWidth]); // Trigger queue manually (duplicates are ignored) LayoutQueue.trigger(); // Get queued functions console.log(LayoutQueue.list()); // [updateLayout] // Clear queue LayoutQueue.clear(); console.log(LayoutQueue.list()); // []
Debug
Known issues
gotchaFunctions added to the queue are executed in order but only when trigger() is called; if no trigger event (resize/load) fires, they won't run.
fix
Ensure you call LayoutQueue.trigger() manually if needed, or rely on default resize/load events.
affects: >=1.0.0
gotchaAdding the same function multiple times will execute it multiple times; there is no deduplication.
fix
Check with LayoutQueue.list() before adding or clear/re-add as needed.
affects: >=1.0.0
breakingVersion 1.0.0 is the only release; no breaking changes known, but API is minimal and may be considered unstable for production.
fix
Pin to exact version 1.0.0 and test thoroughly; consider alternatives if more features are needed.
affects: 1.0.0
Errors
Common errors & fixes
Uncaught TypeError: LayoutQueue.add is not a function
Improper import in CommonJS environment; package may not export correctly.
fix
Use `import LayoutQueue from 'layout-queue'` with a bundler or use bundle.js script tag.
Uncaught ReferenceError: LayoutQueue is not defined
Forgot to include the library or used ES module in a non-module script context.
fix
Add <script src='bundle.js'> before using LayoutQueue, or ensure ES module import is supported.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
47 hits · last 30 days
node
38
OpenAI (training)
1
Resources
layout-queue — npm install layout-queue · libregistry