Accuracy
Why a browser timer can lose time.
JavaScript can ask a browser to run code after a delay, but that delay is not a guarantee. The browser may postpone callbacks while a tab is hidden, a device is saving battery, or the main thread is busy.
The fragile approach
A simple countdown subtracts one every time a one-second interval fires. If ten callbacks are delayed while the device sleeps, only one second may be subtracted when execution resumes. The display is now behind the real clock.
The timestamp approach
A more reliable timer records the intended finish time. Every visual update calculates the difference between that timestamp and the current wall time. Delayed rendering may look momentarily frozen, but the next update corrects itself instead of accumulating drift.
What the browser still cannot promise
An alert can be delayed by operating-system sleep, notification permissions, audio policies, or aggressive background suspension. A web timer should therefore be treated as a convenient attention tool, not a safety alarm for medicine, cooking hazards, industrial processes, or other critical deadlines.
Practical checks
Test the alert once before relying on it. Keep device volume audible, allow notifications when useful, and use the screen wake lock only when the display must remain visible. For a shared event, the target timestamp remains correct even if individual viewers open the page at different times.