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 🙏

© 2024 – Pkg Stats / Ryan Hefner

perf-har-poon

v1.0.1

Published

A tool that runs Puppeteer and Lighthouse to generate HAR files. Available as a library and server.

Downloads

129

Readme

HARpoon

A nautically themed tool that runs Puppeteer and Lighthouse to generate HAR files.

⚠️ Please consider taking action to end whaling ⚠️

Using the NodeJS library

npm install perf-har-poon

blubber is asynchronous. It uses workers to spin up Puppeteer, so you can call it on a bunch of URLs in parallel.

import { blubber } from "perf-har-poon"

// You can get the HAR data for a web page visit...
const { har } = await blubber({ url: "URL_TO_TEST" })

// Or specific Lighthouse reports, if you want them.
const { report } = await blubber({ url: "URL_TO_TEST", audits: ["network-rtt", "errors-in-console"] })

// You could override the default Chrome args, but you shouldn't.
const { har } = await blubber({ url: "URL_TO_TEST", chromeArgs: ["--headless"] })

blubber returns a Promise that resolves with an object that looks like this:

{ 
    url: "URL" // The URL you entered 
    har: { } // HAR data associated with visiting the web page
    report: { } // A Lighthouse report in JSON format, if "audits" were given in the POST body
}

If you want to read the Lighthouse logs, set logLevel:

// You can read the logs from Lighthouse.
const { har } = await blubber({ url: "URL_TO_TEST", logLevel: "verbose" })

Using the Docker container

From Docker hub

docker run -itd --rm -p 3000:3000 doramatadora/har-poon

Build it yourself

Clone this repo and build the container using make:

make image # builds the Docker image for this service
make run # runs the Docker image and listens on http://0.0.0.0:3000/
make stop # you guessed it

Env vars you can set for the server: ADDRESS (defaults to 0.0.0.0) and PORT (defaults to 3000)

API

GET or POST to /throw?url=[URL]

curl --location 'http://0.0.0.0:3000/throw?url=URL_TO_TEST' \
-H 'Content-Type: application/json' \
--data '{ "audits": ["errors-in-console"] }'

Response (JSON)

{
    "url": "[URL]",
    "har": { },
    "report": { }
}

POST body – all properties are optional:

  • audits - A list of Lighthouse audit IDs
  • chromeArgs - Override Chrome args (you won't need this)
{
    "audits": ["...", "..."], 
    "chromeArgs": ["...", "..."] 
}

A list of Lighthouse performance audits? Ok sure

[
  "bootup-time",
  "critical-request-chains",
  "cumulative-layout-shift",
  "diagnostics",
  "dom-size",
  "duplicated-javascript",
  "efficient-animated-content",
  "final-screenshot",
  "first-contentful-paint",
  "first-meaningful-paint",
  "font-display",
  "interactive",
  "largest-contentful-paint",
  "largest-contentful-paint-element",
  "layout-shift-elements",
  "lcp-lazy-loaded",
  "legacy-javascript",
  "long-tasks",
  "main-thread-tasks",
  "mainthread-work-breakdown",
  "max-potential-fid",
  "metrics",
  "modern-image-formats",
  "network-requests",
  "network-rtt",
  "network-server-latency",
  "no-document-write",
  "non-composited-animations",
  "offscreen-images",
  "performance-budget",
  "prioritize-lcp-image",
  "redirects",
  "render-blocking-resources",
  "screenshot-thumbnails",
  "script-treemap-data",
  "server-response-time",
  "speed-index",
  "third-party-facades",
  "third-party-summary",
  "timing-budget",
  "total-blocking-time",
  "total-byte-weight",
  "unminified-css",
  "unminified-javascript",
  "unsized-images",
  "unused-css-rules",
  "unused-javascript",
  "user-timings",
  "uses-long-cache-ttl",
  "uses-optimized-images",
  "uses-passive-event-listeners",
  "uses-rel-preconnect",
  "uses-rel-preload",
  "uses-responsive-images",
  "uses-text-compression",
  "viewport",
  "errors-in-console"
]