0.1.0 • Published 6 years ago

haast v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Haast

travis codecov

Collect web pages meaningful performance metrics.

Quickstart

Installation

npm install haast

Usage

import haast from 'haast'

const metrics = await haast('https://google.com')
console.log(metrics)
{
  timings: {
    navigationStart: 0,
    domContentLoaded: 200,
    firstPaint: 400,
    firstContentfulPaint: 400,
    firstMeaningfulPaint: 600,
    load: 1000
  }
  events: {
    /* ... */
  }
}

API

haast(url)

Loads the given URL and returns a promise resolving to collected metrics.

const metrics = await haast('https://google.com')

metrics(callback)

Accepts a callback that handles navigation and returns a promise when it's done. The page argument is a Puppeteer page instance.

const metrics = await haast(page => {
  await page.goto('http://www.nooooooooooooooo.com')
  await page.click('#no-button')
})