demo · v133
Page lifecycle state machine
The energy-saver freeze sits inside the existing page-lifecycle state machine. Watch the live state for this tab move between active, passive, hidden, frozen, and terminated — and what events fire on each transition.
stateactive
statepassive
statefrozen
stateterminated
document.visibilityState
document.wasDiscarded
pings since attach
persistent draft
—document.wasDiscarded
—pings since attach
0persistent draft
(not saved)
switch to another tab and stay away for several minutes to provoke freeze on Energy Saver.
the four hooks you actually need
document.addEventListener("freeze", () => { localStorage.draft = current; });
document.addEventListener("resume", () => { current = localStorage.draft; });
document.addEventListener("visibilitychange", () => { /* pause heavy work */ });
window.addEventListener("pagehide", (e) => { if (e.persisted) parkInBfcache(); });
Pre-energy-saver, freeze on the desktop only fired when you closed the browser or when bfcache evicted. Now it fires reliably after ~5 min of background + CPU-busy, so every web app that holds in-memory state (WIP forms, draft uploads, undo buffers) should ship a freeze handler that persists state to localStorage or IndexedDB.