<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Robiul Islam</title>
    <description>The latest articles on DEV Community by Robiul Islam (@robiul_islam_cadd1a18a891).</description>
    <link>https://dev.to/robiul_islam_cadd1a18a891</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4212536%2F7ee1cc99-4265-4884-bf3b-fd3625b18b13.jpg</url>
      <title>DEV Community: Robiul Islam</title>
      <link>https://dev.to/robiul_islam_cadd1a18a891</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robiul_islam_cadd1a18a891"/>
    <language>en</language>
    <item>
      <title>Measuring Human Reaction Time in the Browser Without Fooling Yourself</title>
      <dc:creator>Robiul Islam</dc:creator>
      <pubDate>Wed, 04 Nov 2026 17:13:48 +0000</pubDate>
      <link>https://dev.to/robiul_islam_cadd1a18a891/measuring-human-reaction-time-in-the-browser-without-fooling-yourself-nmp</link>
      <guid>https://dev.to/robiul_islam_cadd1a18a891/measuring-human-reaction-time-in-the-browser-without-fooling-yourself-nmp</guid>
      <description>&lt;p&gt;Reaction time tests look simple. Show a signal, wait for a click, subtract two timestamps. But if you have ever tried to build one, you quickly learn that the browser adds its own small delays, and those delays can blur the result.&lt;/p&gt;

&lt;p&gt;Here are the main things worth knowing if you want a fair measurement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use a high resolution clock
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Date.now()&lt;/code&gt; only gives whole milliseconds and can jump if the system clock changes. For timing, &lt;code&gt;performance.now()&lt;/code&gt; is the better choice because it is monotonic and offers finer resolution. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance/now" rel="noopener noreferrer"&gt;MDN page on performance.now&lt;/a&gt; explains the details, including why browsers deliberately reduce its precision for security.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start the clock when the pixels change
&lt;/h2&gt;

&lt;p&gt;A common mistake is starting the timer the moment you change a colour in JavaScript. The screen does not update until the next frame is painted.&lt;/p&gt;

&lt;p&gt;Using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame" rel="noopener noreferrer"&gt;requestAnimationFrame&lt;/a&gt; to start timing closer to the paint helps line the clock up with what the user actually sees.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;showSignal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;go&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pointerdown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;performance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;start&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Remember the hardware
&lt;/h2&gt;

&lt;p&gt;On a 60 Hz display a new frame appears roughly every 16.7 milliseconds, so the signal can appear up to one frame later than your code expects. Mice, touchscreens and keyboards add their own input delay too.&lt;/p&gt;

&lt;p&gt;None of this can be fully removed in a browser. The practical answer is consistency. Testing on the same device each time keeps comparisons fair.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use pointerdown, not click
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;click&lt;/code&gt; event fires after the button is released. &lt;code&gt;pointerdown&lt;/code&gt; fires on press, which is much closer to the moment the user actually reacts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Randomise the wait
&lt;/h2&gt;

&lt;p&gt;If the signal always appears after the same delay, people learn the rhythm and start guessing. A random wait of a second or a few seconds keeps the test honest. Also catch early clicks and treat them as false starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Average several attempts
&lt;/h2&gt;

&lt;p&gt;Single results are noisy. Collect five or more attempts, drop obvious outliers and show the average. Users get a far more meaningful number.&lt;/p&gt;

&lt;h2&gt;
  
  
  See it in action
&lt;/h2&gt;

&lt;p&gt;For a finished example, try &lt;a href="https://voltreflex.com" rel="noopener noreferrer"&gt;VoltReflex&lt;/a&gt;, a free browser based reaction time test. Give it a few rounds and compare your average on different devices. You may be surprised how much the hardware changes the result.&lt;/p&gt;

&lt;p&gt;If you are building your own version, start simple, measure carefully and be honest with users about what a browser can and cannot measure.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building a Browser Reaction Timer: Five Timing Mistakes to Avoid</title>
      <dc:creator>Robiul Islam</dc:creator>
      <pubDate>Wed, 28 Oct 2026 08:32:31 +0000</pubDate>
      <link>https://dev.to/robiul_islam_cadd1a18a891/building-a-browser-reaction-timer-five-timing-mistakes-to-avoid-32pd</link>
      <guid>https://dev.to/robiul_islam_cadd1a18a891/building-a-browser-reaction-timer-five-timing-mistakes-to-avoid-32pd</guid>
      <description>&lt;p&gt;A reaction timer looks simple: show a cue, wait for a click, and display milliseconds. The tricky part is deciding what that number actually measures.&lt;/p&gt;

&lt;p&gt;For a practical example of the kind of interaction discussed here, try the &lt;a href="https://voltreflex.com/" rel="noopener noreferrer"&gt;VoltReflex reaction time test&lt;/a&gt;. When building your own version, keep these five design decisions in mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Separate the states
&lt;/h2&gt;

&lt;p&gt;Use explicit states such as idle, waiting, ready, and result. A click during waiting is an early response, not a valid result. A second click after a result should not overwrite it. Keeping these cases separate makes the interface easier to test.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Do not treat a timeout as the measured interval
&lt;/h2&gt;

&lt;p&gt;A timeout can schedule a cue, but its requested delay is not proof that the browser displayed the cue at that exact moment. Record a start timestamp when handling the cue transition and subtract it from the response timestamp. Keep your start and end timestamps in the same clock domain.&lt;/p&gt;

&lt;p&gt;In JavaScript, performance.now() is useful for elapsed-time measurements. Avoid mixing it with Date.now(). Also describe the result honestly: a browser measurement includes software and device effects, rather than isolating human processing time.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Keep the response path small
&lt;/h2&gt;

&lt;p&gt;Do not put a network request, animation setup, or a large DOM update before recording the response. Capture the timestamp first, then update the score display. Choose a consistent input event and explain it: pointerdown and click mark different moments in an interaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Cancel interrupted rounds
&lt;/h2&gt;

&lt;p&gt;If the page becomes hidden during a round, cancel that attempt and invite the user to start again. Similarly, clear any pending cue when resetting the test. Otherwise an old callback can change the screen in the middle of a new round.&lt;/p&gt;

&lt;p&gt;A useful manual check is to start a round, switch tabs, return, and reset. No delayed cue from the abandoned round should appear afterward.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Show a series, not just a personal best
&lt;/h2&gt;

&lt;p&gt;A single fastest attempt is a poor summary of a session. Display the valid attempts and a median alongside the best result. Keep early responses separate rather than silently turning them into unusually fast scores.&lt;/p&gt;

&lt;p&gt;When comparing sessions, use the same device, browser, and input method where possible. A change in hardware can change the measurement conditions. Avoid presenting a casual browser score as a medical assessment or a direct measure of gaming ability.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small test checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An early response produces clear feedback.&lt;/li&gt;
&lt;li&gt;Reset clears pending callbacks.&lt;/li&gt;
&lt;li&gt;Repeated input records only one result.&lt;/li&gt;
&lt;li&gt;A hidden tab invalidates the current round.&lt;/li&gt;
&lt;li&gt;Keyboard and pointer controls have understandable instructions.&lt;/li&gt;
&lt;li&gt;The result explains what was measured and preserves previous valid attempts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The useful goal is a repeatable interaction with clear limitations. A precise-looking millisecond number only becomes informative when the surrounding behavior is consistent.&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
