An open API service indexing awesome lists of open source software.

https://github.com/csabapalfi/pagespeed-insights-scripts

Small scripts and recipes to run PageSpeed Insights via the API, save results, summarise and export to tsv.
https://github.com/csabapalfi/pagespeed-insights-scripts

cli google lab-data pagespeed pagespeed-insights perfmatters tsv web-performance

Last synced: about 1 month ago
JSON representation

Small scripts and recipes to run PageSpeed Insights via the API, save results, summarise and export to tsv.

Awesome Lists containing this project

README

        

# PageSpeed Insights scripts

Small scripts and recipes to run PageSpeed Insights via the API, save results, summarise and export to tsv.

- [PageSpeed Insights scripts](#pagespeed-insights-scripts)
- [Setup](#setup)
- [Dependencies](#dependencies)
- [Get an API key and set `PSI_API_KEY`](#get-an-api-key-and-set-psi_api_key)
- [Save your URLs to test in `urls.tsv`](#save-your-urls-to-test-in-urlstsv)
- [Usage](#usage)
- [Capture a snapshot](#capture-a-snapshot)
- [Capture snapshots every 5 mins](#capture-snapshots-every-5-mins)
- [Show lab data report](#show-lab-data-report)
- [Save lab data report as tsv](#save-lab-data-report-as-tsv)
- [Caveats](#caveats)

## Setup

### Dependencies

- `bash`
- `node>12`
- no node modules or anything else to install

### Get an API key and set `PSI_API_KEY`

See https://developers.google.com/speed/docs/insights/v5/get-started

`export PSI_API_KEY=`

### Save your URLs to test in `urls.tsv`

- the expected format is `url\tname`, e.g. `https://web.dev/ homepage`
- name is optional, the default name is the URL path

```bash
cat > urls.tsv < -> `

Example:

```bash
./lab-report snapshots/ /fast/
```

Output:

```
Timestamp FCP LCP CLS TBT Score URL
2021-03-19 21:48:49 1.8 s 2.0 s 0 60 ms 98 /fast/
2021-03-19 21:49:00 1.8 s 2.1 s 0 70 ms 98 /fast/
```

### Save lab data report as tsv

`NO_FORMAT=1 NO_COLOR=1 ./summarize-reports [snapshotsDirectory] [filter] > tsvFileName`

Save PageSpeed Insights **lab data** report into `tsvFileName`:

- without colors or formatting
- ready to be imported into e.g. Google Sheets

The tsv rows will have the following fields:

- `Timestamp`: ISO date time value
- `FCP`, `LCP`, `CLS` and `TBT` lab data raw numeric values
- `Score` 0-100 performance score
- `URL` the requested URL path (or name), or in case of a redirect ` -> `

Example:

```bash
NO_FORMAT=1 NO_COLOR=1 ./lab-report snapshots/ > data.csv
```

Files created:

```
data.tsv
```

## Caveats

- few nights hack
- no tests
- not originally intended for public consumption