{"id":45271,"library":"layout-queue","title":"Layout Queue","description":"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.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/davejtoews/layout-queue","tags":["javascript","layout","queue","window","resize"],"install":[{"cmd":"npm install layout-queue","lang":"bash","label":"npm"},{"cmd":"yarn add layout-queue","lang":"bash","label":"yarn"},{"cmd":"pnpm add layout-queue","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default ES module export; CommonJS require might not work if package does not provide a CJS build.","wrong":"const LayoutQueue = require('layout-queue')","symbol":"LayoutQueue","correct":"import LayoutQueue from 'layout-queue'"},{"note":"For CommonJS environments, try the incorrect pattern first, but may need .default fallback.","wrong":"const LayoutQueue = require('layout-queue') // Only works if package has CJS export","symbol":"LayoutQueue","correct":"const LayoutQueue = require('layout-queue').default || require('layout-queue')"},{"note":"Bundle approach exposes LayoutQueue globally; no import needed.","wrong":"","symbol":"LayoutQueue (browser script tag)","correct":"<script src='node_modules/layout-queue/bundle.js'><script> LayoutQueue.add(...)"}],"quickstart":{"code":"import LayoutQueue from 'layout-queue';\n\nfunction updateLayout(size) {\n  console.log(`Resized to ${size}px`);\n  // Update elements\n}\n\nLayoutQueue.add(updateLayout, [window.innerWidth]);\n\n// Trigger queue manually (duplicates are ignored)\nLayoutQueue.trigger();\n\n// Get queued functions\nconsole.log(LayoutQueue.list()); // [updateLayout]\n\n// Clear queue\nLayoutQueue.clear();\nconsole.log(LayoutQueue.list()); // []","lang":"javascript","description":"Demonstrates importing LayoutQueue, adding a function with arguments, triggering execution, listing, and clearing the queue."},"warnings":[{"fix":"Ensure you call LayoutQueue.trigger() manually if needed, or rely on default resize/load events.","message":"Functions 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check with LayoutQueue.list() before adding or clear/re-add as needed.","message":"Adding the same function multiple times will execute it multiple times; there is no deduplication.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pin to exact version 1.0.0 and test thoroughly; consider alternatives if more features are needed.","message":"Version 1.0.0 is the only release; no breaking changes known, but API is minimal and may be considered unstable for production.","severity":"breaking","affected_versions":"1.0.0"}],"env_vars":null,"search_vec":"'action':20 'affect':19 'ajax':50 'altern':53 'condit':26 'custom':47 'davejtoew':29 'debounc':59 'develop':27 'e.g':49 'ensur':61 'event':43 'execut':15,63 'function':32 'handler':57 'ifram':51 'initi':68 'javascript':10,74 'layout':1,4,18,75 'layout-affect':17 'layout-queu':3 'librari':11 'lightweight':9 'load':40,52 'low':72 'mainten':73 'manag':13 'manual':55 'order':37,64 'predict':62 'prevent':24 'queue':2,5,31,76 'race':25 'releas':69 'resiz':23,42,56,78 'sequenti':14 'sinc':67 'stabl':70 'support':45 'trigger':34,48 'updat':66 'v1.0.0':6 'window':22,39,77","created_at":"2026-06-07T12:54:12.405915+00:00","updated_at":"2026-06-07T12:54:12.405915+00:00","problems":[{"fix":"Use `import LayoutQueue from 'layout-queue'` with a bundler or use bundle.js script tag.","cause":"Improper import in CommonJS environment; package may not export correctly.","error":"Uncaught TypeError: LayoutQueue.add is not a function"},{"fix":"Add <script src='bundle.js'> before using LayoutQueue, or ensure ES module import is supported.","cause":"Forgot to include the library or used ES module in a non-module script context.","error":"Uncaught ReferenceError: LayoutQueue is not defined"}],"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/davejtoews/layout-queue#readme","github":"https://github.com/davejtoews/layout-queue","docs":null,"changelog":null,"pypi":null,"npm":"layout-queue","openapi_spec":null,"status_page":null,"smithery":null,"categories":["performance"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}