pixijs-environments

Configure PixiJS v8 with DOMAdapter for non-browser environments.

Updated Mar 13, 2022
One-click install
npx skills add https://github.com/alexkafer/alexkafer-web --skill pixijs-environments-alexkafer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pixijs-environments
Source: https://github.com/alexkafer/alexkafer-web/tree/main/.agents/skills/pixijs-environments
Command: npx skills add https://github.com/alexkafer/alexkafer-web --skill pixijs-environments-alexkafer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PixiJS commonly assumes a standard browser environment, so it breaks in Web Workers, OffscreenCanvas setups, Node/SSR, and CSP-restricted contexts where DOM access and eval-based compilation aren’t available.

Core Features & Use Cases

  • Adapter-based non-browser execution: Use DOMAdapter.set(...) to route all DOM/canvas/Image/XML/fetch work through the right adapter for the environment.
  • Environment-specific imports: Load curated PixiJS bundles like pixi.js/browser or pixi.js/webworker to avoid DOM-only modules when you need static module registration.
  • Web Worker + OffscreenCanvas bootstrapping: Transfer an OffscreenCanvas from the main thread and initialize PixiJS inside the worker with WebWorkerAdapter.
  • Strict CSP compatibility: Preload the CSP polyfill via pixi.js/unsafe-eval to remove reliance on eval/new Function during shader compilation and sync.
  • Custom Adapter for Node/SSR/headless: Implement the full Adapter interface to make PixiJS run in headless testing or server rendering.

Quick Start

Use this skill by calling DOMAdapter.set(WebWorkerAdapter) before creating new Application() in your worker, then initialize with app.init({ canvas, width, height }) using an OffscreenCanvas passed from the main thread.

Frequently Asked Questions about pixijs-environments

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run PixiJS v8 in a Web Worker with OffscreenCanvas?

To run PixiJS v8 in a Web Worker, call `DOMAdapter.set(WebWorkerAdapter)` before `app.init()` using an OffscreenCanvas transferred from the main thread, routing all DOM/canvas work through the worker environment.

Why does PixiJS break in Node or server-side rendering environments?

PixiJS breaks in Node and SSR environments because it assumes standard browser DOM access, requiring an explicit adapter layer to route canvas, Image, and fetch operations through environment-appropriate implementations.

How do I configure PixiJS to work with a strict Content Security Policy (CSP)?

To satisfy strict CSP, import `pixi.js/unsafe-eval` to preload the CSP polyfill, removing PixiJS reliance on eval and new Function during shader compilation and synchronization.

What is the best way to load PixiJS bundles for non-browser environments?

The best way to load PixiJS for non-browser environments is using curated subpath bundles like `pixi.js/browser` or `pixi.js/webworker` to avoid DOM-only modules when static module registration is needed.

Can I use PixiJS for headless testing without a standard browser DOM?

Yes, you can use PixiJS for headless testing by implementing the full Adapter interface to route all DOM, canvas, Image, XML, and fetch work through custom environment-appropriate implementations.

When do I need to configure the DOMAdapter in my PixiJS application?

You must configure `DOMAdapter.set(...)` before calling `app.init()` whenever running PixiJS outside standard browser environments, such as in Web Workers, Node, SSR, or CSP-restricted runtimes.