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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vite-plugin-fps-meter

v1.0.0

Published

vite-plugin-fps-meter is a tiny Vite plugin that overlays a live FPS / ms badge (with p95/p99 and Long Task %) on your app. It can auto-inject in dev or build, toggles via URL/localStorage, adapts to Vite's error overlay, and exposes a simple runtime API.

Readme

npm GitHub package version NPM Downloads

Install

# yarn
yarn add -D vite-plugin-fps-meter

# pnpm
pnpm add -D vite-plugin-fps-meter

# npm
npm i -D vite-plugin-fps-meter

Quick Start

// vite.config.ts
import { defineConfig } from 'vite';
import fpsMeter from 'vite-plugin-fps-meter';

export default defineConfig({
  plugins: [
    fpsMeter({
      // Show badge only in dev by default ("dev" | "build" | boolean)
      enabled: 'dev',

      // Optional fine-tuning (defaults shown below in Options)
      position: 'tl',
      maxDisplayFps: 240,
    }),
  ],
});

How it looks / Works

  • Click the badge to cycle: FPS → ms → p95 → p99.
  • Long Task % shows how much time (in the last update window) was spent in Long Tasks (if supported by the browser).
  • The badge will automatically move to the bottom if Vite's error overlay appears while your preferred position is top.
  • A tiny in-memory window is used to compute percentiles.

Options

| Field | Type | Default | Description | |:----------------------:|:------------------------------------------------:|:------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------| | enabled | boolean | 'dev' | 'build' | 'dev' | Controls when the runtime is injected and started. 'dev' = Vite serve, 'build' = during build preview/runtime, true/false to force on/off. | | updateIntervalMs | number | 250 | UI update interval (ms). | | smoothingTauMs | number | 300 | EMA smoothing time constant (ms). | | skipFrameThresholdMs | number | 400 | Skip frames with dt above this threshold (e.g., tab switches) to avoid skewing EMA. | | pauseOnHidden | boolean | true | Pause meter when document.hidden is true. | | maxDisplayFps | number | 240 | Cap displayed FPS. | | position | 'tl' | 'tr' | 'bl' | 'br' | 'tl' | Badge position: top/bottom & left/right. | | zIndex | number | 2147483647 | CSS z-index of the badge. | | storageKey | string | 'vite:fps-meter' | LocalStorage key for persisted toggle. | | showInIframe | boolean | true | If false, the meter won't render inside iframes. | | percentileWindowSize | number | 300 | Number of recent frame durations used to compute p95/p99. |

Runtime controls

  • URL param: ?fps=1 to force-enable, ?fps=0 to force-disable on first load.
  • Persistence: state is saved in localStorage['vite:fps-meter'] (customizable via storageKey).
  • Global API (injected):
// Toggle at runtime
window.__fpsMeter?.setEnabled(false);
window.__fpsMeter?.setEnabled(true);

// Read current state
const on = window.__fpsMeter?.isEnabled();

Programmatic init (advanced)

By default, the plugin auto-injects and auto-starts. If you need a custom instance, you can import the virtual client and mount manually:

// Somewhere in your app (advanced usage)
import initFpsMeter from 'virtual:fps-meter-client';

const dispose = initFpsMeter({ position: 'br' });
// ...later
dispose();

Note: manual init will create another badge in addition to the auto-injected one. Prefer the global API above unless you have a specific reason to manage instances yourself.

Notes on metrics

  • FPS and ms are derived from a smoothed EMA of frame durations.
  • p95/p99 are computed over a small sliding window of recent frames to avoid heavy allocations.
  • Long Task % uses PerformanceObserver with { type: 'longtask', buffered: true }. If unsupported, it's silently disabled.

Compatibility

  • Vite: peer dependency ^5 | ^6 | ^7.
  • Node: >=18.
  • Works in iframes unless showInIframe: false is set.

License

MIT