Keeping time accurately in a browser
JavaScript timers are not reliable clocks. setInterval and setTimeout guarantee a minimum delay rather than an exact one, and they are delayed by anything occupying the main thread. Accumulating elapsed time by counting intervals therefore drifts, and the drift compounds over a long duration.
Browsers also throttle timers in background tabs, commonly to once per second and sometimes far less, and mobile browsers may suspend them entirely when a page is not visible. A timer built by counting ticks will be substantially wrong after a few minutes in a background tab.
The correct approach is to record the target end time when the timer starts and compute the remaining time from the system clock on each update. The display then stays accurate regardless of how irregularly updates occur, and a timer returning from a background tab immediately shows the correct value rather than a value that stopped counting.
Getting the alert to arrive
Browsers block audio that has not been initiated by a user gesture, which is why a timer's alarm sometimes fails silently. The reliable pattern is to create the audio context when the user starts the timer, so the eventual sound plays under a permission already granted.
Device behaviour adds further limits. A phone with the screen locked may suspend the page entirely, and mobile browsers are aggressive about reclaiming resources from background tabs. Notifications are more reliable than sound in that situation, but require permission and are still subject to system do-not-disturb settings.
The honest summary is that a browser timer is well suited to something you are present for and unreliable as an alarm you depend on while away. For anything consequential — a medication reminder, an appointment, waking up — use your device's own alarm, which the operating system guarantees.
Timing things well
Different tasks want different signals. A countdown suits anything with a fixed duration, while a count-up stopwatch suits work of unknown length where you want to know how long it took. Interval timers with alternating work and rest periods suit exercise and structured practice.
For cooking, remember that stated times assume specific conditions — pan size, starting temperature, altitude and oven calibration all shift them, and most domestic ovens differ from their dial by a noticeable margin. Times are a guide and the food is the authority.
A visible countdown creates useful time pressure for focused work but can be a distraction if you watch it. Positioning the timer out of direct view, and relying on the alert rather than the display, generally works better. For structured work sessions specifically, the pomodoro timer handles the cycle of intervals and breaks.