Bash.tv → GitHub → itch.io

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 GitHub

Game 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

5. Avoid busy work

6. Settings and signals

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.”