← All guidesGuide

Why Accurate Browser Timers Use Timestamps

A browser can delay visual callbacks when the tab is hidden or the device is busy. Accurate timing should not assume callbacks always happen on schedule.

The interval problem

Adding a fixed amount every interval can accumulate error because an interval scheduled for a precise moment may actually run later.

Use timestamps as the source of truth

A stopwatch can calculate current high resolution time minus its start mark. A countdown can calculate a fixed target timestamp minus the current timestamp.

Rendering is separate

The screen can refresh as often as practical while elapsed or remaining time always comes from the timestamp calculation.

Ready to try it?

Open the matching browser tool and switch into fullscreen when you want the display to take over.

Open clocksOpen timers