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.
- Host: GitHub
- URL: https://github.com/csabapalfi/pagespeed-insights-scripts
- Owner: csabapalfi
- Created: 2019-03-06T08:50:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-04T23:50:51.000Z (about 4 years ago)
- Last Synced: 2025-03-25T10:37:42.339Z (about 2 months ago)
- Topics: cli, google, lab-data, pagespeed, pagespeed-insights, perfmatters, tsv, web-performance
- Language: JavaScript
- Homepage:
- Size: 590 KB
- Stars: 21
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 SheetsThe 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