Blog · 3 min read ·

How to Measure Reaction Time Accurately in a Browser

A reaction time test sounds trivial: turn a box green, see how long the click takes. But a few details decide whether the number means anything. Here's how my Reaction Time Test handles them.

Use the right clock

Date.now() counts whole milliseconds and can jump if the system clock changes. performance.now() is a steady clock made for measuring durations, with sub-millisecond precision. The test reads it at the moment the box turns green and again when you press.

Press, not click

A "click" event fires when you release the button. Your reaction is the press. The test listens for pointerdown, which fires on press, and works the same for a mouse, a trackpad or a finger.

Make it unpredictable

If green always came after two seconds, you'd learn the rhythm and "react" before seeing anything. The delay is random, between 1.2 and 3.7 seconds. Pressing early counts as a false start and the try doesn't count.

Average several tries

One try is noisy. The test takes five and reports the average, and shows every try so you can see how steady you are. A typical adult averages around 250 milliseconds. Screens and input devices add their own small delay, so compare results on the same device.

Test your reaction time.