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