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

performance-event-timing-polyfill

v0.5.4

Published

Provide a polyfill for the PerformanceEventTiming interface

Readme

performance-event-timing-polyfill

Overview

This is a small library which provides a polyfill for the PerformanceEventTiming API such that is enough for measuring INP across all browsers.

Why is this useful?

Currently only Chromium based browsers are reporting INP data. This means that interactivity of sites can be improved only for these browsers. Reality is that other browsers like Safari and Firefox exist and in some cases they form the largest visitor base for a website. Not having data for the user experience there means these sites cannot be optimized for the users of these browsers. Chromium's data cannot be used as a proxy because we know that:

  • events are handled differently sometimes
  • third parties might behave differently for these browsers
  • the site itself might have different behavior for these browsers

Using this library you can get INP data for all browsers and ensure great user experience for everybody :tada:

Demo

You can test how the polyfill works on this modified version of the popular INP demo page.

Usage

Basic usage

In order to ensure most accurate results load the script as early in your page as possible. Make sure to load it before you load your code which measures INP.

<script src="https://unpkg.com/performance-event-timing-polyfill"></script>

Custom timing calculation

By default the polyfill will try to emulate native PerformanceEventTiming API entries. However internally the library is tracking the events a bit more granularly. You can subscribe to the raw event measure entries and calculate INP yourself, if you so desire (not recommended).

import { onInteraction } from 'https://unpkg.com/performance-event-timing-polyfill?module';
onInteraction(console.log);

Browser support

All major browsers are supported. For Chrome, the polyfill doesn't activate by default since this API is provided natively. But the event observer is still active. This means you can still use onInteraction() from this library which could be useful if you need apples to apples comparisons across browsers.

Caveats

Overlapping interactions

When there are overlapping interactions, attribution comes out a bit off currently. Further investigation is needed.

Must be loaded early

Data may be off if this polyfill is not loaded early enough in the page lifecycle. Ideally it should be loaded before any event listeners are registered and before any performance observers are created. This is needed to ensure that the event handlers added by this library are the first to execute. Otherwise calls to stopImmediatePropagation() can prevent the library from detecting an event.

Not all events are measured

Only pointerdown, mousedown, pointerup, mouseup, pointercancel, click, auxclick, contextmenu, keydown, keypress, keyup are measured for now.

Development

Building the code

To build the code once (production) run

npm run build

To build and watch for changes (dev) run

npm run dev

Contributing

Feel free to open issues or PRs to report issues or suggest improvements!