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

assetassure-resource-collector

v0.3.0

Published

Browser library that observes loaded JS/CSS resources and reports them to the AssetAssure API

Readme

assetassure-resource-collector

Browser library that observes JS and CSS resources loaded by a page and reports their URIs and types, together with the URL of the page that loaded them, to the AssetAssure API in batches.

Install

npm install assetassure-resource-collector

Or load the minified build from a CDN. It exposes the class as window.AssetAssureResourceCollector:

<script src="https://unpkg.com/assetassure-resource-collector"></script>
<script>
    new AssetAssureResourceCollector({
        publicToken: 'your-public-token',
        apiDomain: 'api.example.assetassure.io',
    }).start();
</script>

Usage

import { ResourceCollector } from 'assetassure-resource-collector';

const collector = new ResourceCollector({
    publicToken: 'your-public-token',
    apiDomain: 'api.example.assetassure.io',
    resourceTypes: ['js', 'css'],
    onError: (error) => console.warn(error),
});

collector.start();

// Later, to disconnect the observer and flush anything still pending:
await collector.stop();

CommonJS is supported too:

const { ResourceCollector } = require('assetassure-resource-collector');

Options

| Option | Required | Default | Description | | ----------------- | -------- | --------- | --------------------------------------------------------------------------- | | publicToken | yes | | Public token used for Basic auth against the AssetAssure API. | | apiDomain | yes | | Must match api.<subdomain>.assetassure.io. | | resourceTypes | no | ['js'] | Any of 'js', 'css'. See Classification. | | batchSize | no | 50 | URIs per request. Keep bodies small: keepalive requests are capped at 64 KB. | | flushIntervalMs | no | 2000 | Periodic flush interval. 0 disables the timer. | | signedUrlTtlMs | no | 60000 | How long a signed URL is reused before a fresh one is requested. | | onError | no | | Called with an Error when a request fails. Errors are otherwise swallowed. |

Behaviour

  • Each batch is posted as { "pageUrl": "<origin + pathname>", "resources": [{ "uri": "...", "type": "js" | "css" }, ...] }. The page URL is captured when the resource is observed, so single-page applications get one batch per route. Query string and fragment are stripped in the browser so session identifiers never leave the page. pageUrl is omitted when location is unavailable.
  • Only resources not seen before on the current page URL are reported. The same resource is reported again when it is seen on another page.
  • Pending URIs are sent when a full batch accumulates, on the flush interval, when the page is hidden, on pagehide, and on stop().
  • A rejected upload triggers one signed URL refresh and retry before the error is reported.
  • start() is a no-op where PerformanceObserver is unavailable.

Classification

Resources are classified from what the browser knows about them, not from the URL alone, so scripts without a .js extension are reported too.

| Type | Reported when | | ----- | ------------------------------------------------------------------------------------------------------ | | js | PerformanceResourceTiming.initiatorType is script (any <script src>, for example https://js.stripe.com/v3/), or the URL path ends in .js / .mjs (dynamic import(), workers). | | css | The URL path ends in .css. The css initiator type is deliberately not used: it marks fonts and images loaded by a stylesheet. |

Query string and fragment are ignored when checking the extension, so gtm.js?id=X is a script. Fetch/XHR responses, images, fonts and iframes are never reported.

Development

npm install
npm run build   # emits dist/ (ESM, CommonJS, minified IIFE)
npm test        # node:test against src/

Releasing

Releases are published to npm by GitHub Actions whenever a v* tag is pushed. The workflow authenticates with npm trusted publishing, so no token is stored in the repository, and every release carries a provenance attestation.

npm version patch   # or minor / major
git push --follow-tags

The tag must match the version in package.json; the workflow fails otherwise. Build and tests run via prepublishOnly before anything is uploaded.