How to Use This Tool
Switch between the stopwatch and the countdown at the top. Both keep time from the system clock rather than by counting intervals, which is what makes them survive a background tab.
Why most web timers drift
The natural way to build a timer is to run setInterval every second and add one to a
counter. It is wrong, and the reason is in the specification: setInterval guarantees the
callback fires no sooner than the delay, not that it fires on time.
When the browser is busy, a garbage collection runs, or another tab takes the main thread, the callback is late. A counter-based timer never learns about that lateness — each tick still adds exactly one second — so the error accumulates and only ever goes one way. Over an hour it is typically several seconds short.
Recording the start time and computing now − start on each frame removes the whole
problem. The display might stutter if the browser is busy; the number cannot be wrong, because it is
being read rather than counted.
Background tabs make it much worse
Browsers deliberately throttle timers in hidden tabs to save battery — typically to once per second, and after a few minutes to once a minute or less. Mobile browsers may suspend a background tab entirely.
A counter-based timer loses everything that happened while it was throttled. A timestamp-based one shows the correct time the instant you switch back, because it never needed the ticks in the first place.
The alarm has a limitation worth knowing
Sound is played through the Web Audio API, which requires a user interaction before it will make any noise — pressing start counts. If you load the page and immediately expect an alarm without touching anything, browsers will block it, and that is a deliberate protection against pages that autoplay audio.
A suspended mobile tab may also not run the code that triggers the alarm at all until you return. For anything that genuinely must wake you, a phone's own alarm is the right tool; a browser tab is not designed for it and the platforms actively prevent it.
Laps and splits
The stopwatch records both, and they answer different questions:
- Lap — the time for that segment alone.
- Split — the total elapsed at that point.
For intervals or repeats you want the lap column; for tracking progress against a target you want the split. The fastest and slowest laps are marked, because that is usually the thing you are looking for.
