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.
Source: sickn33/agentic-awesome-skills → skills/game-development/web-games/SKILL.md
Also appears in: sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/game-development/web-games/SKILL.md, sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/game-development/web-games/SKILL.md
1---
2name: web-games
3description: ">- Web browser game development. Framework selection (Phaser, PixiJS, Kaplay, Canvas/WebGL, Three.js, Babylon.js), hybrid DOM+canvas, WebGPU, optimization, PWA, audio unlock. Use when building HTML5/WebGL/WebGPU games or choosing a browser runtime."
4category: media-and-creative
5source_repo: sickn33/agentic-awesome-skills
6source_path: "skills/game-development/web-games/SKILL.md"
7source_url: https://github.com/sickn33/agentic-awesome-skills/blob/HEAD/skills/game-development/web-games/SKILL.md
8metadata:
9 source: https://skillmd.com/skills/thedixitjain/web-games
10---
11
12
13# Web Browser Game Development
14
15> Framework selection and browser-specific principles. For stack choice details see `game-development/engine-selection`.
16
17---
18
19## 1. Framework Selection
20
21### Decision Tree
22
23```
24What type of game?
25│
26├── 2D Game
27│ ├── Full game engine features? → Phaser 4
28│ ├── Fast prototype / jam? → Kaplay
29│ ├── Raw rendering power? → PixiJS 8
30│ └── Tiny / no dependency? → Raw Canvas / WebGL
31│
32├── 3D Game
33│ ├── Full engine (physics, XR)? → Babylon.js
34│ └── Rendering focused? → Three.js
35│
36├── Hybrid (DOM UI + canvas moments)
37│ └── Custom shell + guest viewport
38│ (Canvas/Kaplay/Phaser/Pixi inside a region/modal)
39│
40└── Narrative-first
41 └── Ink (inkjs) or Twine export + DOM host
42```
43
44### Comparison
45
46| Framework | Type | Best For |
47|-----------|------|----------|
48| **Raw Canvas / WebGL** | 2D / low-level | Small scope, full control |
49| **Kaplay** | 2D toolkit | Rapid prototypes |
50| **Phaser 4** | 2D engine | Full game features |
51| **PixiJS 8** | 2D renderer | Rendering, custom systems |
52| **Three.js** | 3D renderer | Visualizations, lightweight 3D |
53| **Babylon.js** | 3D engine | Full engine, XR |
54
55### Hybrid shell + guest
56
57Use when chrome is HTML (menus, inventories, text, dashboards) but bursts of play need a canvas:
58
591. Mount guest in a container; pass context in.
602. Run a **local** game loop in the guest.
613. Return results (score, pass/fail); **destroy** guest (RAF, listeners, GL context as needed).
62
63Do not let the guest own global app routing unless the product *is* a full-screen game.
64
65---
66
67## 2. WebGPU Adoption
68
69### Browser Support (2025)
70
71| Browser | Support |
72|---------|---------|
73| Chrome | ✅ Since v113 |
74| Edge | ✅ Since v113 |
75| Firefox | ✅ Since v131 |
76| Safari | ✅ Since 18.0 |
77| **Total** | **~73%** global |
78
79### Decision
80
81- **New GPU-heavy projects**: Use WebGPU with WebGL fallback
82- **Broad legacy / simple 2D**: Start with WebGL or Canvas 2D
83- **Feature detection**: Check `navigator.gpu`
84
85---
86
87## 3. Performance Principles
88
89### Browser Constraints
90
91| Constraint | Strategy |
92|------------|----------|
93| No local file access | Asset bundling, CDN |
94| Tab throttling | Pause when hidden (`visibilitychange`) |
95| Mobile data limits | Compress assets |
96| Audio autoplay | Require user interaction |
97
98### Optimization Priority
99
1001. **Asset compression** - KTX2, Draco, WebP
1012. **Lazy loading** - Load on demand
1023. **Object pooling** - Avoid GC
1034. **Draw call batching** - Reduce state changes
1045. **Web Workers** - Offload heavy computation
105
106---
107
108## 4. Asset Strategy
109
110| Type | Format |
111|------|--------|
112| Textures | KTX2 + Basis Universal (or WebP/PNG for simple 2D) |
113| Audio | WebM/Opus (fallback: MP3) |
114| 3D Models | glTF + Draco/Meshopt |
115
116| Phase | Load |
117|-------|------|
118| Startup | Core assets, <2MB |
119| Gameplay | Stream on demand |
120| Background | Prefetch next level |
121
122---
123
124## 5. PWA for Games
125
126**Benefits:** offline play, install, fullscreen, optional push.
127**Requirements:** service worker, web app manifest, HTTPS.
128
129---
130
131## 6. Audio Handling
132
133- Create/resume `AudioContext` on first click/tap
134- Prefer Web Audio API; pool sources; preload common SFX
135- Compress with WebM/Opus when possible
136
137---
138
139## 7. Anti-Patterns
140
141| ❌ Don't | ✅ Do |
142|----------|-------|
143| Load all assets upfront | Progressive loading |
144| Ignore tab visibility | Pause when hidden |
145| Block on audio load | Lazy load audio |
146| Skip compression | Compress everything |
147| Assume fast connection | Handle slow networks |
148| Leave canvas engines running off-screen | Tear down guests |
149
150---
151
152> **Remember:** Browser is the most accessible platform. Respect its constraints.
153
154## When to Use
155
156Use when building HTML5/WebGL/WebGPU games, choosing a browser runtime, or wiring hybrid DOM+canvas guests.
157
158## Limitations
159
160- Use this skill only when the task clearly matches the scope described above.
161- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
162- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
163
164---
165
166**Source:** [`sickn33/agentic-awesome-skills`](https://github.com/sickn33/agentic-awesome-skills) → `skills/game-development/web-games/SKILL.md`
167
168**Also appears in:** `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills/skills/game-development/web-games/SKILL.md`, `sickn33/agentic-awesome-skills/plugins/agentic-awesome-skills-claude/skills/game-development/web-games/SKILL.md`