Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
How does browser respond in various situations when window is not focused?

Say you have a single-page app with some JavaScript that has a few different pieces of functionality:

  • A polling operation which updates the UI every 5 seconds with notifications.
  • A websocket connection (or HTTP server-side events) which tells the browser to hard refresh with location.reload() if some new changes to the codebase are deployed.
  • A 15 minute timer that logs you out after 15 minutes (clears cookies and calls logout from the frontend).

What happens in these scenarios across browsers:

  1. You switch tabs in the browser, and blur (lose focus) on your web app?
  2. You blur out of the tab, minimize the browser, then open the browser back up?
  3. You close your laptop lid and reopen it again?

For 2 and 3, there are two additional cases:

  1. You leave the tab out of focus (i.e. the web app is in another tab hidden away).
  2. Or alternatively you focus back in on your web app tab.

What happens here to the timers and server-sent events / websockets? Do they still work? If you start the 15 minute timer, then close your computer for 20 minutes, and open it back up, and never focus back in on the tab, will it log you out?

A few years ago I implemented a "logout after x interval of time" piece of functionality, like your bank probably has. But I forget exactly the intricacies of how it works in these situations, so it would be helpful to write them down as notes for the next person to benefit from.

From my understanding and basic/partial tests:

  1. If you simply blur your tab (i.e. visit another tab other than your web app), and a timer or websockets or events are going to trigger a page refresh, the page will refresh even if it is in another tab that is blurred.
  2. If you start a 15 minute timer, close your computer for 5 minutes, and open it back up, but never focus your window, will the timer continue spinning for 15 minutes, or only 10 minutes?
  3. If you start a 15 minute timer, close your computer for 20 minutes, and open it back up but don't focus, will it log you out behind the scenes?

Summary

To summarize:

  1. What happens when you tab out of your application and/or close your laptop and reopen it, does everything continue where it left off, not work at all, or what?
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda