Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!