Web Browser Game Development
Framework selection and browser-specific principles. For stack choice details see game-development/engine-selection.
1. Framework Selection
Decision Tree
What type of game?
│
├── 2D Game
│ ├── Full game engine features? → Phaser 4
│ ├── Fast prototype / jam? → Kaplay
│ ├── Raw rendering power? → PixiJS 8
│ └── Tiny / no dependency? → Raw Canvas / WebGL
│
├── 3D Game
│ ├── Full engine (physics, XR)? → Babylon.js
│ └── Rendering focused? → Three.js
│
├── Hybrid (DOM UI + canvas moments)
│ └── Custom shell + guest viewport
│ (Canvas/Kaplay/Phaser/Pixi inside a region/modal)
│
└── Narrative-first
└── Ink (inkjs) or Twine export + DOM host
Comparison
| Framework |
Type |
Best For |
| Raw Canvas / WebGL |
2D / low-level |
Small scope, full control |
| Kaplay |
2D toolkit |
Rapid prototypes |
| Phaser 4 |
2D engine |
Full game features |
| PixiJS 8 |
2D renderer |
Rendering, custom systems |
| Three.js |
3D renderer |
Visualizations, lightweight 3D |
| Babylon.js |
3D engine |
Full engine, XR |
Hybrid shell + guest
Use when chrome is HTML (menus, inventories, text, dashboards) but bursts of play need a canvas:
- Mount guest in a container; pass context in.
- Run a local game loop in the guest.
- Return results (score, pass/fail); destroy guest (RAF, listeners, GL context as needed).
Do not let the guest own global app routing unless the product is a full-screen game.
2. WebGPU Adoption
Browser Support (2025)
| Browser |
Support |
| Chrome |
✅ Since v113 |
| Edge |
✅ Since v113 |
| Firefox |
✅ Since v131 |
| Safari |
✅ Since 18.0 |
| Total |
~73% global |
Decision
- New GPU-heavy projects: Use WebGPU with WebGL fallback
- Broad legacy / simple 2D: Start with WebGL or Canvas 2D
- Feature detection: Check
navigator.gpu
3. Performance Principles
Browser Constraints
| Constraint |
Strategy |
| No local file access |
Asset bundling, CDN |
| Tab throttling |
Pause when hidden (visibilitychange) |
| Mobile data limits |
Compress assets |
| Audio autoplay |
Require user interaction |
Optimization Priority
- Asset compression - KTX2, Draco, WebP
- Lazy loading - Load on demand
- Object pooling - Avoid GC
- Draw call batching - Reduce state changes
- Web Workers - Offload heavy computation
4. Asset Strategy
| Type |
Format |
| Textures |
KTX2 + Basis Universal (or WebP/PNG for simple 2D) |
| Audio |
WebM/Opus (fallback: MP3) |
| 3D Models |
glTF + Draco/Meshopt |
| Phase |
Load |
| Startup |
Core assets, <2MB |
| Gameplay |
Stream on demand |
| Background |
Prefetch next level |
5. PWA for Games
Benefits: offline play, install, fullscreen, optional push.
Requirements: service worker, web app manifest, HTTPS.
6. Audio Handling
- Create/resume
AudioContext on first click/tap
- Prefer Web Audio API; pool sources; preload common SFX
- Compress with WebM/Opus when possible
7. Anti-Patterns
| ❌ Don't |
✅ Do |
| Load all assets upfront |
Progressive loading |
| Ignore tab visibility |
Pause when hidden |
| Block on audio load |
Lazy load audio |
| Skip compression |
Compress everything |
| Assume fast connection |
Handle slow networks |
| Leave canvas engines running off-screen |
Tear down guests |
Remember: Browser is the most accessible platform. Respect its constraints.
When to Use
Use when building HTML5/WebGL/WebGPU games, choosing a browser runtime, or wiring hybrid DOM+canvas guests.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
1---2name: web-games3description: >-4 Web browser game development. Framework selection (Phaser, PixiJS, Kaplay,5 Canvas/WebGL, Three.js, Babylon.js), hybrid DOM+canvas, WebGPU, optimization,6 PWA, audio unlock. Use when building HTML5/WebGL/WebGPU games or choosing a7 browser runtime.8risk: none9source: community10date_added: "2026-02-27"11metadata:12 source: https://skillmd.com/skills/mhassan0000/web-games13---1415# Web Browser Game Development1617> Framework selection and browser-specific principles. For stack choice details see `game-development/engine-selection`.1819---2021## 1. Framework Selection2223### Decision Tree2425```26What type of game?27│28├── 2D Game29│ ├── Full game engine features? → Phaser 430│ ├── Fast prototype / jam? → Kaplay31│ ├── Raw rendering power? → PixiJS 832│ └── Tiny / no dependency? → Raw Canvas / WebGL33│34├── 3D Game35│ ├── Full engine (physics, XR)? → Babylon.js36│ └── Rendering focused? → Three.js37│38├── Hybrid (DOM UI + canvas moments)39│ └── Custom shell + guest viewport40│ (Canvas/Kaplay/Phaser/Pixi inside a region/modal)41│42└── Narrative-first43 └── Ink (inkjs) or Twine export + DOM host44```4546### Comparison4748| Framework | Type | Best For |49|-----------|------|----------|50| **Raw Canvas / WebGL** | 2D / low-level | Small scope, full control |51| **Kaplay** | 2D toolkit | Rapid prototypes |52| **Phaser 4** | 2D engine | Full game features |53| **PixiJS 8** | 2D renderer | Rendering, custom systems |54| **Three.js** | 3D renderer | Visualizations, lightweight 3D |55| **Babylon.js** | 3D engine | Full engine, XR |5657### Hybrid shell + guest5859Use when chrome is HTML (menus, inventories, text, dashboards) but bursts of play need a canvas:60611. Mount guest in a container; pass context in.622. Run a **local** game loop in the guest.633. Return results (score, pass/fail); **destroy** guest (RAF, listeners, GL context as needed).6465Do not let the guest own global app routing unless the product *is* a full-screen game.6667---6869## 2. WebGPU Adoption7071### Browser Support (2025)7273| Browser | Support |74|---------|---------|75| Chrome | ✅ Since v113 |76| Edge | ✅ Since v113 |77| Firefox | ✅ Since v131 |78| Safari | ✅ Since 18.0 |79| **Total** | **~73%** global |8081### Decision8283- **New GPU-heavy projects**: Use WebGPU with WebGL fallback84- **Broad legacy / simple 2D**: Start with WebGL or Canvas 2D85- **Feature detection**: Check `navigator.gpu`8687---8889## 3. Performance Principles9091### Browser Constraints9293| Constraint | Strategy |94|------------|----------|95| No local file access | Asset bundling, CDN |96| Tab throttling | Pause when hidden (`visibilitychange`) |97| Mobile data limits | Compress assets |98| Audio autoplay | Require user interaction |99100### Optimization Priority1011021. **Asset compression** - KTX2, Draco, WebP1032. **Lazy loading** - Load on demand1043. **Object pooling** - Avoid GC1054. **Draw call batching** - Reduce state changes1065. **Web Workers** - Offload heavy computation107108---109110## 4. Asset Strategy111112| Type | Format |113|------|--------|114| Textures | KTX2 + Basis Universal (or WebP/PNG for simple 2D) |115| Audio | WebM/Opus (fallback: MP3) |116| 3D Models | glTF + Draco/Meshopt |117118| Phase | Load |119|-------|------|120| Startup | Core assets, <2MB |121| Gameplay | Stream on demand |122| Background | Prefetch next level |123124---125126## 5. PWA for Games127128**Benefits:** offline play, install, fullscreen, optional push.129**Requirements:** service worker, web app manifest, HTTPS.130131---132133## 6. Audio Handling134135- Create/resume `AudioContext` on first click/tap136- Prefer Web Audio API; pool sources; preload common SFX137- Compress with WebM/Opus when possible138139---140141## 7. Anti-Patterns142143| ❌ Don't | ✅ Do |144|----------|-------|145| Load all assets upfront | Progressive loading |146| Ignore tab visibility | Pause when hidden |147| Block on audio load | Lazy load audio |148| Skip compression | Compress everything |149| Assume fast connection | Handle slow networks |150| Leave canvas engines running off-screen | Tear down guests |151152---153154> **Remember:** Browser is the most accessible platform. Respect its constraints.155156## When to Use157158Use when building HTML5/WebGL/WebGPU games, choosing a browser runtime, or wiring hybrid DOM+canvas guests.159160## Limitations161162- Use this skill only when the task clearly matches the scope described above.163- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.164- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.