konfeti - v0.6.0
    Preparing search index...

    Function createWorker

    • Create Worker Instance. Simulation and drawing move to a Web Worker (the canvas becomes an OffscreenCanvas), so confetti stays smooth while the page is busy. Falls back to the main thread when OffscreenCanvas is unsupported. Options must be worker-safe: no hooks, easing functions, Path2D, DOM images or defineShape / definePhysics extensions (see WorkerFireOptions).

      Parameters

      • Optionalcanvas: HTMLCanvasElement | null

        Target Canvas (null or omitted creates a fullscreen overlay)

      • Optionaloptions: WorkerCreateOptions

        Worker Instance Options

      Returns WorkerKonfetiInstance

      Worker Instance

      import { createWorker } from "konfeti/worker";

      const stage = createWorker(document.querySelector("canvas"));
      stage.fire({ particleCount: 400, spread: 360 });
      stage.isWorker(); // true where OffscreenCanvas is supported

      Lives in its own entry (konfeti/worker), so apps that never render in a worker carry none of this code.