Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Living wiki of UI design patterns and best practices built with Fumadocs, Next.js, and Base UI components.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
rules/context-reuse-single.md
1---2title: Reuse Single AudioContext3impact: HIGH4tags: context, audio-context, singleton5---67## Reuse Single AudioContext89Reuse a single AudioContext instance; do not create new ones per sound.1011**Incorrect (new context per call):**1213```ts14function playSound() {15const ctx = new AudioContext();16}17```1819**Correct (singleton):**2021```ts22let audioContext: AudioContext | null = null;2324function getAudioContext(): AudioContext {25if (!audioContext) {26audioContext = new AudioContext();27}28return audioContext;29}30```31