
Pixijs Environments
Run PixiJS v8 in Web Workers, Node/SSR, headless setups, or strict CSP pages using DOMAdapter and unsafe-eval polyfill.
Overview
PixiJS Environments is an agent skill for the Build phase that configures PixiJS v8 DOMAdapter, workers, OffscreenCanvas, Node/SSR, and CSP-safe init outside a standard browser.
Install
npx skills add https://github.com/pixijs/pixijs-skills --skill pixijs-environmentsWhat is this skill?
- DOMAdapter.set before app.init for BrowserAdapter, WebWorkerAdapter, or custom adapters
- Web Worker pattern with OffscreenCanvas transferred from the main thread
- pixi.js/unsafe-eval import for CSP contexts blocking eval
- Covers Node, SSR, headless, and CSP-restricted triggers from skill metadata
- Points to pixijs-application and pixijs-migration-v8 related skills
Adoption & trust: 1.3k installs on skills.sh; 206 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
PixiJS breaks in workers, Node, or CSP-locked pages because DOM APIs are missing or eval is blocked.
Who is it for?
Indie game or interactive UI builders using PixiJS v8 who need workers for performance, server rendering, or enterprise CSP headers.
Skip if: Standard single-page browser apps that already work with default BrowserAdapter and no CSP eval restrictions.
When should I use this skill?
Running PixiJS v8 outside a standard browser: Web Workers, OffscreenCanvas, Node/SSR, or CSP-restricted contexts; triggers on DOMAdapter, unsafe-eval, headless.
What do I get? / Deliverables
Your agent initializes PixiJS with the correct adapter, worker canvas handoff, and unsafe-eval polyfill order before app.init().
- Adapter selection and DOMAdapter.set placement before init
- Worker or SSR bootstrap code with canvas transfer or polyfill imports
Recommended Skills
Journey fit
This skill targets implementation-time renderer setup in non-standard JavaScript runtimes, which sits squarely in the Build phase for frontends and interactive apps. Canvas, OffscreenCanvas, and adapter swaps are front-end rendering concerns even when the host is Node or a worker thread.
How it compares
Adapter and runtime skill—not a replacement for pixijs-application browser bootstrap or full migration guides.
Common Questions / FAQ
Who is pixijs-environments for?
Solo developers and small teams rendering with PixiJS v8 in workers, headless Node, SSR, or locked-down CSP environments.
When should I use pixijs-environments?
During Build when you see DOMAdapter, OffscreenCanvas, Web Worker, Node, headless, SSR, CSP, or unsafe-eval in your PixiJS task.
Is pixijs-environments safe to install?
It is MIT-licensed documentation patterns; confirm versions against your lockfile and review the Security Audits panel on this catalog page before trusting third-party skill sources.
SKILL.md
READMESKILL.md - Pixijs Environments
`DOMAdapter` abstracts every piece of DOM access PixiJS does (canvas creation, Image loading, fetch, XML parsing) so the library can run in non-browser contexts. Call `DOMAdapter.set(...)` before `app.init()` to swap in a different adapter. ## Quick Start ```ts // worker.ts — OffscreenCanvas posted from main thread DOMAdapter.set(WebWorkerAdapter); self.onmessage = async (event) => { const app = new Application(); await app.init({ canvas: event.data.canvas, width: 800, height: 600, }); }; ``` For CSP contexts that block `unsafe-eval`, import the polyfill before any renderer init: ```ts import "pixi.js/unsafe-eval"; ``` **Related skills:** `pixijs-application` (standard browser init), `pixijs-migration-v8` (settings removal, adapter changes). ## Core Patterns ### Web Worker with OffscreenCanvas Transfer an OffscreenCanvas from the main thread, then initialize PixiJS in the worker: ```ts // main.ts const canvas = document.createElement("canvas"); canvas.width = 800; canvas.height = 600; document.body.appendChild(canvas); const offscreen = canvas.transferControlToOffscreen(); const worker = new Worker("worker.ts", { type: "module" }); worker.postMessage({ canvas: offscreen }, [offscreen]); ``` ```ts // worker.ts import { Application, DOMAdapter, WebWorkerAdapter } from "pixi.js"; DOMAdapter.set(WebWorkerAdapter); self.onmessage = async (event) => { const app = new Application(); await app.init({ canvas: event.data.canvas, width: 800, height: 600, }); }; ``` `DOMAdapter.set(WebWorkerAdapter)` must happen before `new Application()`. The WebWorkerAdapter uses `OffscreenCanvas` instead of `document.createElement('canvas')` and `@xmldom/xmldom` for XML parsing. Features that do **not** work inside a Web Worker (no DOM access): - `DOMContainer` — there is no real DOM node to overlay. - `AccessibilitySystem` — depends on live DOM focus and screen reader hooks. - `FontFace` loading via the Font Loading API — use pre-converted bitmap fonts (`BitmapFont.install` or `.fnt` assets) instead. ### Environment-specific subpath imports Instead of importing `pixi.js`, you can pull in a curated bundle for each environment: ```ts import "pixi.js/browser"; // accessibility, dom, events, spritesheet, rendering, filters import "pixi.js/webworker"; // spritesheet, rendering, filters (no DOM-only modules) ``` `pixi.js/webworker` deliberately omits `accessibility`, `dom`, and `events` because they require the DOM. Use these subpath entries when you want static, synchronous module registration instead of relying on `loadEnvironmentExtensions` to dynamic-import the right set at renderer init. ### loadEnvironmentExtensions ```ts import { loadEnvironmentExtensions } from "pixi.js"; await loadEnvironmentExtensions(false); // false = load defaults; true = skip ``` `loadEnvironmentExtensions(skip)` replaces the deprecated `autoDetectEnvironment` helper (since 8.1.6). Pass `true` to opt out of auto-loading the default browser extensions when you are bootstrapping a custom environment. `autoDetectEnvironment(add)` still exists as a shim that forwards to `loadEnvironmentExtensions(!add)`. ### CSP-compliant setup PixiJS uses `new Function()` internally for shader compilation and uniform syncing. In Content Security Policy environments that block `unsafe-eval`, import the polyfill: ```ts import "pixi.js/unsafe-eval"; import { Application } from "pixi.js"; const app = new Application(); await app.init({ width: 800, height: 600 }); ``` The `pixi.js/unsafe-eval`