DEV Community

Cover image for How I Built a Real-Time Display Refresh Rate Tester Using Astro.js & requestAnimationFrame
Refreshrate
Refreshrate

Posted on

How I Built a Real-Time Display Refresh Rate Tester Using Astro.js & requestAnimationFrame

As developers, gamers, and tech enthusiasts, we often invest in high refresh rate monitors (120Hz, 144Hz, or even 240Hz). But here is a common problem: just because your operating system settings say 144Hz doesn't mean your browser is actually rendering at that speed.

Sometimes, a faulty HDMI/DP cable, incorrect GPU settings, or browser hardware acceleration issues can silently cap your frame rate at 60Hz.

I needed a quick, installation-free way to verify my actual screen refresh rate directly in the browser. Since I couldn't find a lightweight tool that was completely ad-free and minimal, I decided to build one myself.

Here is introducing: Refresh Rate Tester.

The Tech Stack

I wanted the tool to be extremely fast and lightweight. Here is what I used:

  • Astro.js: For building a highly optimized, static, and zero-JS-by-default foundation.
  • Tailwind CSS: For clean, responsive styling that looks great on both desktop and mobile.
  • Vanilla JavaScript: For the core logic.

How It Works Under the Hood

The core logic relies entirely on the browser's native requestAnimationFrame API.

Instead of trying to read system-level hardware settings (which browsers can't easily do anyway for security reasons), the script calculates the time difference between consecutive screen repaints.

Here is a simplified version of how the logic works:

let frameCount = 0;
let lastTime = performance.now();
let currentHz = 0;

function calculateRefreshRate() {
    let now = performance.now();
    frameCount++;

    // Update the Hz every second (1000 milliseconds)
    if (now - lastTime >= 1000) {
        currentHz = frameCount;
        console.log(`Current Refresh Rate: ${currentHz} Hz`);

        // Reset for the next second
        frameCount = 0;
        lastTime = now;
    }

    // Loop the function for the next frame paint
    requestAnimationFrame(calculateRefreshRate);
}

// Start the loop
requestAnimationFrame(calculateRefreshRate);
Enter fullscreen mode Exit fullscreen mode

By counting how many frames the browser can paint in one single second, we get the exact screen refresh rate (Hz). Since all calculations run entirely on the client side in your browser, there is zero server latency involved, ensuring 100% accuracy.

πŸš€Try It Out

You can test your own display's refresh rate instantly here:
πŸ”— refreshrate.net

No app installation or plugins are requiredβ€”it works directly in your browser on both mobile and desktop.

I'd love to hear your feedback on the UI, the performance, or if you have any suggestions for new features (like adding motion blur tests or frame skipping tests in the future).

Drop a comment below! Let me know what Hz your current screen is running at. πŸ‘‡

Top comments (0)