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/impl-preload-audio.md
1---2title: Preload Audio Files3impact: MEDIUM4tags: impl, preload, performance5---67## Preload Audio Files89Preload audio files to avoid playback delay.1011**Incorrect (loads on demand):**1213```tsx14function playSound(name: string) {15const audio = new Audio(`/sounds/${name}.mp3`);16audio.play();17}18```1920**Correct (preloaded):**2122```tsx23const sounds = {24success: new Audio("/sounds/success.mp3"),25error: new Audio("/sounds/error.mp3"),26};2728Object.values(sounds).forEach(audio => audio.load());2930function playSound(name: keyof typeof sounds) {31sounds[name].currentTime = 0;32sounds[name].play();33}34```35