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

lighthouse-batch-parallel

v1.0.15

Published

> :warning: **Running Lighthouse concurrently would skew [Performamce Score](https://developers.google.com/web/tools/lighthouse/v3/scoring#perf)** according to this [reply from Lighthouse team](https://github.com/GoogleChrome/lighthouse/issues/7104#issuec

Downloads

356

Readme

lighthouse-batch-parallel

:warning: Running Lighthouse concurrently would skew Performamce Score according to this reply from Lighthouse team, be careful of giving workersNum argument when the accuracy of performance score is important.

This is a module to help collecting website's Lighthouse audit data in batches.

You can require this module in your own project, get the report data stream in CSV, JS Object or JSON format and handle the stream by yourself, or you can just use the cli-tool which is also provided to generate the report file.

It has the capability to monitor multiple websites in parallel which can accelerate the collecting process when the target URLs are in plenty, but please be aware of the warning. You can decide how many workers working at the same time, every worker would launch an independent headless Chrome browser.

Usage

npm:

$ npm i lighthouse-batch-parallel

yarn:

$ yarn add lighthouse-batch-parallel

Example

const { lighthouseBatchParallel } = require('lighthouse-batch-parallel');

const targetWebsites = [
  {
    Device: 'mobile',
    URL:    'https://www.npmjs.com/package/lighthouse-batch-parallel'
  },
  {
    Device: 'desktop',
    URL:    'https://www.npmjs.com/package/lighthouse-batch-parallel'
  },
];

const customAuditsConfig = {
  'first-contentful-paint': 'First Contentful Paint',
  'first-meaningful-paint': 'First Meaningful Paint',
  'speed-index':            'Speed Index',
};

const lighthouseAuditing = lighthouseBatchParallel({ 
  input: {
    stream: targetWebsites,
  },
  customAudits: { stream: customAuditsConfig },
  throttling:   'applied3G',
  outputFormat: 'jsObject',
  workersNum:   2,
});

let reports = [];

lighthouseAuditing.on('data', ({ data }) => {
  reports.push(data);
});

lighthouseAuditing.on('error', ({ error }) => {
  console.log(error);
});

lighthouseAuditing.on('end', () => {
  console.log(reports);
  console.log(reports[0].audits);
});

Output of example above:

// console.log(reports);
[
  {
    Device: 'mobile',
    URL: 'https://www.npmjs.com/package/react-carousel-slider',
    audits: {
      performance: [Object],
      accessibility: [Object],
      'best-practices': [Object],
      seo: [Object],
      pwa: [Object],
      'first-contentful-paint': [Object],
      'first-meaningful-paint': [Object],
      'speed-index': [Object]
    }
  },
  {
    Device: 'desktop',
    URL: 'https://www.npmjs.com/package/react-carousel-slider',
    audits: {
      performance: [Object],
      accessibility: [Object],
      'best-practices': [Object],
      seo: [Object],
      pwa: [Object],
      'first-contentful-paint': [Object],
      'first-meaningful-paint': [Object],
      'speed-index': [Object]
    }
  }
]

// console.log(reports[0].audits);
{
  performance: { title: 'Performance', score: 0.42 },
  accessibility: { title: 'Accessibility', score: 0.78 },
  'best-practices': { title: 'Best-practices', score: 1 },
  seo: { title: 'SEO', score: 1 },
  pwa: { title: 'PWA', score: 0.31 },
  'first-contentful-paint': { title: 'First Contentful Paint', score: '2.7 s' },
  'first-meaningful-paint': { title: 'First Meaningful Paint', score: '4.2 s' },
  'speed-index': { title: 'Speed Index', score: '5.9 s' }
}

lighthouseBatchParallel(parameters)

More details on Github

Cli Tool

This cli-tool is a little gadget only takes file as input, and also only generates file as output, it also can be an example to show how to use this module. Install this module globally would be easier to use this cli-tool.

$ npm i lighthouse-batch-parallel -g

Input file

$ lighthouse-batch-parallel your-input.csv

The input file should follow the structure as what is required. Options below can help to pass custom settings to the module.

Options

-a <path>   ||  --audits-config <path>    { Custom audits config }

-t <method> ||  --throttling <method>     { Throttling Method }

-p <path>   ||  --path <path>             { The location of output file }

-f <name>   ||  --file-name <name>        { The name of output file }

-o <format> ||  --output-format <format>  { The output format }

-n <number> ||  --number <number>         { Number of workers }

-l          ||  --log-mode                { Log progress of process }

-e          ||  --error-log-file          { Output error log file}

More details on Github