Background tab throttling
Chrome throttles inactive tabs. Timers slow. WebSocket + SSE may pause. Events queue until foreground.
Advertisement
Page freeze / sleep
Laptop closes → connection dies. Reopens → EventSource auto-reconnects with Last-Event-ID.
Advertisement
Visibility API integration
document.addEventListener('visibilitychange', () => {
if (document.hidden) es.close();
else es = new EventSource('/stream');
});Close SSE on background, reopen on foreground. Saves server resources + battery.