Reduce unnecessary power use in mobile browser games. Stop work when nothing is happening. Pause in hidden tabs, render on demand for static screens (menus, puzzles, turn-based, idle), cap the frame rate when 60 fps isn't needed, lower resolution and effects, avoid busy timers, polling and constant audio, batch network calls, offer a battery-saver setting, and respect reduced-motion and save-da...
Download skill (.zip) Files on GitHubGame battery optimization
Every frame costs power, even if nothing changed. Do no work when nothing is happening.
1. Stop when hidden (always)
document.addEventListener("visibilitychange", () => {
if (document.hidden) { loop.pause(); audio.suspend(); } else { audio.resume(); /* show the pause menu; resume on tap */ }
});
rAF stops in hidden tabs, but setInterval, audio and WebSocket traffic don’t. Suspend them too. (The game-render-loop-optimization
loop.js auto-pauses.)
2. Render only when needed
Menus, puzzle boards, card games, turn-based and idle screens don’t need 60 fps:
const loop = createLoop({ step: 1 / 30, update, render, onDemand: true }); // game-render-loop-optimization loop.js
canvas.addEventListener("pointerdown", () => loop.requestRender()); // and on keys, state changes, tween steps
While a tween or animation runs, request renders every frame; when it ends, stop. For DOM games, CSS transitions are cheaper than JS animation.
3. Cap the frame rate when 60 isn’t needed
loop.setMaxFps(30) for slow games, menus, pause screens and idle phases. A 120 Hz phone rendering a static scene at 120 fps uses far
more power than at 30. Action games stay at 60 during play and drop to 30 in menus.
4. Lighter rendering
- Pixel ratio 1–1.5 on battery saver; fewer particles; no post-processing, shadows or bloom.
- Static backgrounds cached (canvas-performance). Dark backgrounds save power on OLED phones.
5. Avoid busy work
- No polling timers (
setInterval(check, 16)); use events. Nowhileloops waiting for things. - Idle games: simulate offline progress from timestamps (
elapsed = now - lastSeen) instead of running while hidden. - Network: batch updates (multiplayer at 10–20 Hz, not 60), no constant polling. Use one WebSocket.
- Audio: stop music on menus if it isn’t wanted; an
AudioContextwith nothing playing can be suspended. - Vibration sparingly.
6. Settings and signals
- A Battery saver option: 30 fps cap, DPR 1, low effects. Turn it on by default if
navigator.getBattery?.()reports a low battery that isn’t charging (Chrome only, optional). prefers-reduced-motion: fewer animations and no shake.navigator.connection?.saveData: skip background prefetching of big optional assets.
Check
Profile a menu or static screen (game-performance-profiling): renders per second should drop to ~0 when nothing changes, and
main-thread time per second should be near zero. “Title screen: 60 renders/s → 0 when idle; play capped at 60, menus at 30.”