79770825

Date: 2025-09-21 11:21:13
Score: 0.5
Natty:
Report link

You can't prevent the browser from throttling an inactive tab - see this article

Good thing is, you don't need to update the timer when the tab is not visible. When user switches back to this tab, your timer should fire. For getting the time, don't rely on how many times the function passed to setInterval fired. You can either get the time from Date object, or, if you want to display the time received from server (because it's in a specific time zone or something), you can save a Date object when you receive the server response and calculate the difference with a new Date() object

Reasons:
  • Blacklisted phrase (1): this article
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: rajniszp