A stopwatch with laps that stays right when you switch tabs. Most browser stopwatches count ticks from a timer, which drifts — a browser fires an interval no sooner than you asked, never exactly on it, and the shortfalls add up. Worse, browsers throttle background tabs to one tick a second and then roughly one a minute, so a tick-counting stopwatch left running in a hidden tab quietly stops counting. This one reads the clock and subtracts, so the interval only triggers a repaint and the reading is correct however rarely it fires. It uses a monotonic clock too, so a system time change cannot make it run backwards.
| Situation | Tick counter | This |
|---|---|---|
| Running an hour | Drifts seconds behind | Exact |
| Tab in background | Nearly stops | Exact |
| Busy main thread | Loses time | Exact |
| System clock changes | Can jump | Unaffected |
Yes, and correctly — which is the main reason to use this one. Browsers throttle background tabs so heavily that a tick-counting stopwatch stops counting entirely. This reads the clock, so switching away and back gives you the true elapsed time rather than the time the tab happened to be visible.
As accurate as the browser's clock, which is far better than millisecond precision for this purpose. The display is limited to hundredths, deliberately — three digits changing at once is unreadable while it runs, and a stopwatch exists to be read while running.
It stops and the laps are lost. Nothing is stored on a server and nothing survives a reload, which is the trade for a tool that needs no account and sends nothing anywhere.
The split is the time since the previous lap; the total is the time since you started. Both are shown, since a runner wants the lap and a timekeeper wants the total.
Because it is the thing you were timing for. The fastest and slowest appear once there are at least two laps — with one, it is both and highlighting is meaningless.
Space starts and stops, L records a lap, R resets. Reaching for a mouse costs a tenth of a second, which matters when that is what you are measuring.
The elapsed time is read from the clock, never counted from ticks, and that single decision is what separates a stopwatch that is right from one that looks right. `setInterval(fn, 1000)` does not fire every second — it fires no sooner than a second, and whatever the browser was busy with is added on. Those shortfalls accumulate, so a counter incremented on each tick drifts seconds behind over an hour and there is no way to recover the lost time because it was never recorded. Worse, browsers deliberately throttle background tabs: intervals are clamped to one a second when the tab is hidden and, in Chrome, to roughly one a minute after five minutes. A tick-counting stopwatch left running while you work in another tab simply stops counting, then resumes as though no time had passed. Storing the start timestamp and subtracting it on each repaint makes both problems vanish — the interval becomes nothing but a repaint trigger, and the reading is correct no matter how badly or rarely it fired. Pausing records the accumulated duration and resuming sets a new start, so the same arithmetic survives any number of pauses. `performance.now()` is used rather than `Date.now()`, because it is monotonic: a system clock adjustment, an NTP correction or a daylight-saving change can move `Date.now()` backwards and produce a negative elapsed time mid-measurement, which is a rare but genuinely possible way for a stopwatch to report nonsense. Display is hundredths rather than milliseconds, because three digits changing simultaneously cannot be read while running and a stopwatch is meant to be read while it runs. Laps are stored as cumulative marks and converted to splits for display, since both are wanted and only one can be recorded without drift.