Web browser game development principles. Framework selection, WebGPU, optimization, PWA.
Add this skill
npx mdskills install sickn33/web-gamesComprehensive reference guide with clear decision frameworks and modern best practices
1---2name: web-games3description: Web browser game development principles. Framework selection, WebGPU, optimization, PWA.4allowed-tools: Read, Write, Edit, Glob, Grep5---67# Web Browser Game Development89> Framework selection and browser-specific principles.1011---1213## 1. Framework Selection1415### Decision Tree1617```18What type of game?19│20├── 2D Game21│ ├── Full game engine features? → Phaser22│ └── Raw rendering power? → PixiJS23│24├── 3D Game25│ ├── Full engine (physics, XR)? → Babylon.js26│ └── Rendering focused? → Three.js27│28└── Hybrid / Canvas29 └── Custom → Raw Canvas/WebGL30```3132### Comparison (2025)3334| Framework | Type | Best For |35|-----------|------|----------|36| **Phaser 4** | 2D | Full game features |37| **PixiJS 8** | 2D | Rendering, UI |38| **Three.js** | 3D | Visualizations, lightweight |39| **Babylon.js 7** | 3D | Full engine, XR |4041---4243## 2. WebGPU Adoption4445### Browser Support (2025)4647| Browser | Support |48|---------|---------|49| Chrome | ✅ Since v113 |50| Edge | ✅ Since v113 |51| Firefox | ✅ Since v131 |52| Safari | ✅ Since 18.0 |53| **Total** | **~73%** global |5455### Decision5657- **New projects**: Use WebGPU with WebGL fallback58- **Legacy support**: Start with WebGL59- **Feature detection**: Check `navigator.gpu`6061---6263## 3. Performance Principles6465### Browser Constraints6667| Constraint | Strategy |68|------------|----------|69| No local file access | Asset bundling, CDN |70| Tab throttling | Pause when hidden |71| Mobile data limits | Compress assets |72| Audio autoplay | Require user interaction |7374### Optimization Priority75761. **Asset compression** - KTX2, Draco, WebP772. **Lazy loading** - Load on demand783. **Object pooling** - Avoid GC794. **Draw call batching** - Reduce state changes805. **Web Workers** - Offload heavy computation8182---8384## 4. Asset Strategy8586### Compression Formats8788| Type | Format |89|------|--------|90| Textures | KTX2 + Basis Universal |91| Audio | WebM/Opus (fallback: MP3) |92| 3D Models | glTF + Draco/Meshopt |9394### Loading Strategy9596| Phase | Load |97|-------|------|98| Startup | Core assets, <2MB |99| Gameplay | Stream on demand |100| Background | Prefetch next level |101102---103104## 5. PWA for Games105106### Benefits107108- Offline play109- Install to home screen110- Full screen mode111- Push notifications112113### Requirements114115- Service worker for caching116- Web app manifest117- HTTPS118119---120121## 6. Audio Handling122123### Browser Requirements124125- Audio context requires user interaction126- Create AudioContext on first click/tap127- Resume context if suspended128129### Best Practices130131- Use Web Audio API132- Pool audio sources133- Preload common sounds134- Compress with WebM/Opus135136---137138## 7. Anti-Patterns139140| ❌ Don't | ✅ Do |141|----------|-------|142| Load all assets upfront | Progressive loading |143| Ignore tab visibility | Pause when hidden |144| Block on audio load | Lazy load audio |145| Skip compression | Compress everything |146| Assume fast connection | Handle slow networks |147148---149150> **Remember:** Browser is the most accessible platform. Respect its constraints.151
Full transparency — inspect the skill content before installing.