{"id":16902716,"url":"https://github.com/csabapalfi/pagespeed-insights-scripts","last_synced_at":"2025-06-22T12:07:12.604Z","repository":{"id":52212507,"uuid":"174107285","full_name":"csabapalfi/pagespeed-insights-scripts","owner":"csabapalfi","description":"Small scripts and recipes to run PageSpeed Insights via the API, save results, summarise and export to tsv.","archived":false,"fork":false,"pushed_at":"2021-05-04T23:50:51.000Z","size":604,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T14:42:36.878Z","etag":null,"topics":["cli","google","lab-data","pagespeed","pagespeed-insights","perfmatters","tsv","web-performance"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csabapalfi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-06T08:50:06.000Z","updated_at":"2023-11-16T09:27:17.000Z","dependencies_parsed_at":"2022-08-23T21:10:51.310Z","dependency_job_id":null,"html_url":"https://github.com/csabapalfi/pagespeed-insights-scripts","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"purl":"pkg:github/csabapalfi/pagespeed-insights-scripts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csabapalfi%2Fpagespeed-insights-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csabapalfi%2Fpagespeed-insights-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csabapalfi%2Fpagespeed-insights-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csabapalfi%2Fpagespeed-insights-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csabapalfi","download_url":"https://codeload.github.com/csabapalfi/pagespeed-insights-scripts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csabapalfi%2Fpagespeed-insights-scripts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261289420,"owners_count":23136070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","google","lab-data","pagespeed","pagespeed-insights","perfmatters","tsv","web-performance"],"created_at":"2024-10-13T18:07:35.125Z","updated_at":"2025-06-22T12:07:07.561Z","avatar_url":"https://github.com/csabapalfi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PageSpeed Insights scripts\n\nSmall scripts and recipes to run PageSpeed Insights via the API, save results, summarise and export to tsv.\n\n- [PageSpeed Insights scripts](#pagespeed-insights-scripts)\n  - [Setup](#setup)\n    - [Dependencies](#dependencies)\n    - [Get an API key and set `PSI_API_KEY`](#get-an-api-key-and-set-psi_api_key)\n    - [Save your URLs to test in `urls.tsv`](#save-your-urls-to-test-in-urlstsv)\n  - [Usage](#usage)\n    - [Capture a snapshot](#capture-a-snapshot)\n    - [Capture snapshots every 5 mins](#capture-snapshots-every-5-mins)\n    - [Show lab data report](#show-lab-data-report)\n    - [Save lab data report as tsv](#save-lab-data-report-as-tsv)\n  - [Caveats](#caveats)\n\n## Setup\n\n### Dependencies\n\n- `bash`\n- `node\u003e12`\n- no node modules or anything else to install\n\n### Get an API key and set `PSI_API_KEY`\n\nSee https://developers.google.com/speed/docs/insights/v5/get-started\n\n`export PSI_API_KEY=\u003capi-key\u003e`\n\n### Save your URLs to test in `urls.tsv`\n\n- the expected format is `url\\tname`, e.g. `https://web.dev/ homepage`\n- name is optional, the default name is the URL path\n\n```bash\ncat \u003e urls.tsv \u003c\u003cEOF\nhttps://web.dev/\thomepage\nhttps://web.dev/fast/\nEOF\n```\n\n## Usage\n\n### Capture a snapshot\n\n`./captute-snapshot [snapshotsDirectory] [urlsTsvFile]`\n\nSave PageSpeed Insights API results\n\n- in `snapshotsDirectory` (default: `snapshots`)\n- for all URLs in `urlsTsvFile` (default: `urls.tsv`)\n- then show PageSpeed Insights **lab data** summary for current snapshot\n\nExample:\n\n```bash\n./capture-snapshot\n```\n\nOutput:\n\n```\ncreated snapshots/2021-03-19_21-34-27/\nrunning pagespeed insights for https://web.dev/...\nrunning pagespeed insights for https://web.dev/fast/...\n\nScore\tFCP\tLCP\tTBT\tCLS\tTimestamp\t\t\tURL\n95\t1.1 s\t2.8 s\t70 ms\t0\t2021-03-19T21:34:28.785Z\t/fast/\n99\t1.1 s\t1.6 s\t30 ms\t0\t2021-03-19T21:34:29.159Z\thomepage\n```\n\nFiles created:\n\n```\nsnapshots/2021-03-19_21-34-27/homepage.json\nsnapshots/2021-03-19_21-34-27/fast.json\n```\n\n### Capture snapshots every 5 mins\n\nExample:\n\n```bash\nwatch -c -n 300 ./capture-snapshot\n```\n\nOutput:\n\n```\nEvery 300.0s: ./capture-snapshot\n\ncreated snapshots/2021-03-20_00-28-01/\nrunning pagespeed insights for https://web.dev/...\nrunning pagespeed insights for https://web.dev/fast/...\n\nTimestamp               FCP     LCP     CLS     TBT             Score   URL\n2021-03-20 00:28:02      1.8 s   2.1 s   0.001      30 ms          98   /fast/\n2021-03-20 00:28:02      1.8 s   2.6 s       0      40 ms          96   homepage\n```\n\nFiles created:\n\n- Every 5 minutes a timestamp directory is created with the latest results\n\n### Show lab data report\n\n`./lab-report [snapshotsDirectory] [filter]`\n\nShow PageSpeed Insights **lab data** summary:\n\n- for all results in `snapshotsDirectory` recursively (default: current directory)\n- if `filter` is set then only show results where URL or path or name matches `filter` (default: show all URLs)\n\nThe summary shows:\n\n- `Timestamp`: human readable timestamp\n- `FCP`, `LCP`, `CLS` and `TBT` formatted (and colored) lab data values\n- `Score` 0-100 colored performance score\n- `URL` the requested URL path (or name), or in case of a redirect `\u003crequestPathOrName\u003e -\u003e \u003cfinalPath\u003e`\n\nExample:\n\n```bash\n./lab-report snapshots/ /fast/\n```\n\nOutput:\n\n```\nTimestamp          \tFCP   \tLCP   \tCLS  \tTBT      \tScore \tURL\n2021-03-19 21:48:49\t 1.8 s\t 2.0 s\t     0\t    60 ms\t   98\t/fast/\n2021-03-19 21:49:00\t 1.8 s\t 2.1 s\t     0\t    70 ms\t   98\t/fast/\n```\n\n### Save lab data report as tsv\n\n`NO_FORMAT=1 NO_COLOR=1 ./summarize-reports [snapshotsDirectory] [filter] \u003e tsvFileName`\n\nSave PageSpeed Insights **lab data** report into `tsvFileName`:\n\n- without colors or formatting\n- ready to be imported into e.g. Google Sheets\n\nThe tsv rows will have the following fields:\n\n- `Timestamp`: ISO date time value\n- `FCP`, `LCP`, `CLS` and `TBT` lab data raw numeric values\n- `Score` 0-100 performance score\n- `URL` the requested URL path (or name), or in case of a redirect `\u003crequestPathOrName\u003e -\u003e \u003cfinalPath\u003e`\n\nExample:\n\n```bash\nNO_FORMAT=1 NO_COLOR=1 ./lab-report snapshots/ \u003e data.csv\n```\n\nFiles created:\n\n```\ndata.tsv\n```\n\n## Caveats\n\n- few nights hack\n- no tests\n- not originally intended for public consumption\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsabapalfi%2Fpagespeed-insights-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsabapalfi%2Fpagespeed-insights-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsabapalfi%2Fpagespeed-insights-scripts/lists"}