Bash.tv → GitHub → itch.io

Make browser games run smoothly at 60 fps on phones and load fast. Measure first (FPS / frame-time overlay, Chrome performance profile, draw calls), then fix the real bottleneck. CPU (allocation and garbage collection, collision checks, AI), rendering (draw calls, overdraw, canvas state changes, devicePixelRatio, shaders, shadows), memory leaks, loading (asset size, lazy loading, compression), ...

Download skill (.zip) Files on GitHub

Game performance optimization

Measure, then fix the biggest thing, then measure again. Never optimize blind.

1. Measure

// tiny frame-time overlay: draw last in the HUD
let ft = 16.7, worst = 0, last = performance.now();
function perfTick() { const n = performance.now(), d = n - last; last = n; ft += (d - ft) * 0.05; worst = Math.max(worst * 0.99, d); }
function perfDraw(ctx) { ctx.fillStyle = ft > 18 ? "#f55" : "#5f5"; ctx.font = "12px monospace"; ctx.fillText(`${(1000 / ft).toFixed(0)} fps  ${ft.toFixed(1)} ms  worst ${worst.toFixed(0)}`, 8, 14); }

2. Fix by bottleneck

CPU: update is slow

GC: spikes every few seconds

Rendering: render is slow

Memory: gets slower over time

3. Loading

4. Adaptive quality (phones heat up)

// if average frame time stays high for 2 s, step quality down: dpr 2 → 1.5 → 1, particles × 0.5, shadows off
if (ftAvg > 20 && performance.now() - lastChange > 2000 && quality > 0) { quality--; applyQuality(quality); lastChange = performance.now(); }

Offer a “Low graphics” setting too. Keep gameplay identical across quality levels.

Report

Say what you measured (before → after numbers), what you changed, and on which device or size. Example: “Phone frame time 31 ms → 12 ms: cached the tilemap, pooled bullets, capped pixel ratio at 2.”