DEV Community

PatilRB
PatilRB

Posted on Originally published at nixiefx.com

Five hot-path rules for 60 FPS HTML5 games

A web game can look simple and still miss its frame budget. The usual culprit is not a single expensive feature; it is small amounts of work repeated every frame until the garbage collector, renderer, or GPU stalls.

Here are five rules that consistently help.

1. Treat per-frame allocation as a bug

Avoid creating vectors, arrays, closures, and temporary objects inside update loops. Reuse scratch values and keep object shapes stable. A tiny allocation multiplied by thousands of particles becomes visible hitching.

2. Prewarm pools

Pooling only helps if the pool is ready before the action begins. Prewarm projectiles, particles, and transient UI effects during a loading phase. The first explosion should not also be the moment the game constructs hundreds of objects.

3. Use texture atlases deliberately

Atlases reduce texture switches, but a giant atlas is not automatically better. Group assets that are rendered together, keep filtering and color-space settings consistent, and verify that batching actually improves in the profiler.

4. Budget draw calls, not just triangles

Many transparent particle layers can become expensive even when the geometry is tiny. Watch draw calls, overdraw, blend modes, and material changes. Sort only when the visual result truly needs it.

5. Measure frame time, not average FPS

An average can hide a periodic 50 ms hitch. Capture frame-time distributions and inspect the worst frames. Fix the spike before reducing the whole game's visual ambition.

These constraints shaped the NixieFX runtime: authored effects are useful only when their update path stays predictable in a real HTML5 game.

The full guide includes practical pooling, atlas, and profiling examples:

https://nixiefx.com/html5-game-performance/

Top comments (0)