npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

framerate-helper

v1.0.2

Published

A lightweight utility for estimating screen refresh rate and calculating frame-safe animation durations.

Readme

FrameRateHelper.js

FrameRateHelper is a lightweight, zero-dependency JavaScript utility that calculates the user's display refresh rate and provides a stable, clamped frame duration. It is ideal for synchronizing animations with screen refresh rates to produce smooth, consistent visual experiences.

ko-fi

🚀 Features

  • 🔍 Automatically detects true screen refresh rate using requestAnimationFrame
  • 🧠 Falls back to requestIdleCallback or setTimeout when needed
  • 🧱 Built-in clamping prevents duration spikes on slow devices or inactive tabs
  • 📦 Offers methods for calculating precise animation timing
  • 📐 Frame-based timing with optional min/max/rounding controls
  • 🪶 Lightweight and dependency-free — pure vanilla JavaScript

📦 Installation

✅ Use via CDN (for direct browser usage)

jsDelivr:

<!-- Development version (readable, unminified, includes source map) -->
<script src="https://cdn.jsdelivr.net/gh/InfinitumForm/[email protected]/dist/FrameRateHelper.js"></script>

<!-- Production version (minified, optimized for speed) -->
<script src="https://cdn.jsdelivr.net/gh/InfinitumForm/[email protected]/dist/FrameRateHelper.min.js"></script>

unpkg:

<!-- Development version (readable, unminified, includes source map) -->
<script src="https://unpkg.com/[email protected]/dist/FrameRateHelper.js"></script>

<!-- Production version (minified, optimized for speed) -->
<script src="https://unpkg.com/[email protected]/dist/FrameRateHelper.min.js"></script>

This exposes window.FrameRateHelper globally.

✅ Use via NPM (modern JavaScript projects)

npm install framerate-helper

Then in your module:

import FrameRateHelper from 'framerate-helper';

🧪 Usage Tutorial

1. Basic Setup (auto-detect refresh rate)

const fps = new FrameRateHelper();

fps.onReady((hz) => {
  console.log('Detected refresh rate:', hz.toFixed(2), 'Hz');
  console.log('Estimated frame duration:', fps.getDuration(), 'ms');
});

2. Get adjusted duration for animations

const duration = fps.getDuration(300); // base + 300ms offset

3. Calculate animation duration from frame count

const duration = fps.getDurationForFrames(90); // Duration for 90 frames

4. Clamp duration with min/max values

const duration = fps.getDurationForFrames(90, {
  min: 1000,      // minimum 1 second
  max: 2000,      // maximum 2 seconds
  rounded: true   // round to nearest integer
});

5. Animate based on desired frames with fallback

const desiredFrames = 120;
let duration = fps.getDurationForFrames(desiredFrames, {
  max: 2500,   // prevent overly long animations
  min: 800,    // ensure minimum visibility
  rounded: true
});

myElement.style.transitionDuration = `${duration}ms`;

🧰 API Reference

new FrameRateHelper()

Creates a new instance and begins refresh rate measurement immediately.

onReady(callback)

Waits for refresh rate calculation to complete and then executes the callback.

  • callback (function): Receives detected refresh rate (Hz)

getDuration(offset = 0)

Returns an adjusted frame duration based on screen refresh rate.

  • offset (number): Optional duration to add (in ms)
  • Returns: total duration in ms

getDurationForFrames(frames, options)

Calculates duration based on number of frames.

  • frames (number): Desired number of animation frames
  • options (object) (optional):
    • min (number): Minimum allowed duration in ms
    • max (number): Maximum allowed duration in ms
    • rounded (boolean): If true, rounds result
  • Returns: clamped, optionally rounded duration in ms

💡 Real-World Use Cases

jQuery Integration Examples

You can seamlessly use FrameRateHelper (for example) with jQuery animation methods to ensure frame-synced transitions:

const fps = new FrameRateHelper();

fps.onReady(() => {
  const duration = fps.getDuration(400); // add a 400ms offset if desired

  // Smoothly toggle element visibility with frame-accurate duration
  $('.my-element').slideToggle(duration);

  // Show/hide with consistent frame-based speed
  $('.other-element').show(duration);
  $('.another-one').hide(duration);
});

This is especially useful when animations feel "choppy" on devices with non-standard refresh rates (e.g. 120Hz, 144Hz), ensuring consistent experience across screens.

  • Precision animations in sliders, carousels, or onboarding steps
  • Smooth frame-based motion control in games or interactive UIs
  • Avoiding stutters in custom scroll or fade effects
  • Performance-friendly frame sync for canvas/webgl renderers

📄 License

MIT License — free for personal and commercial use.


👤 Author

Developed by INFINITUM FORM®
Author: Ivijan-Stefan Stipić
© 2025 Ivijan-Stefan Stipić. All rights reserved.

ko-fi


For issues, contributions, or improvements, please visit the GitHub repository.

Happy animating! 🎨