This package has been deprecated

Author message:

Please use @lhci/cli instead

pagespeed-score

1.2.7 • Public • Published

pagespeed-score

Build Status Coverage Status

Google PageSpeed score command line toolkit

Get a score and metrics via the Google PageSpeed Insights API or a local Lighthouse run.

Requirements

Usage

npx is the quickest way to try:

$ npx pagespeed-score http://example.com/
name  	score	FCP	SI	LCP	TTI	TBT	CLS
run 1 	100	0.7	0.7	0.7	0.7	0.0	0.00

FCP, SI, LCP, TTI, TBT and CLS are the values for the 6 metrics that affect the score.

Use --help see the list of all options.

multiple runs

--runs <N> overrides the number of runs (default: 1). For more than 1 runs stats will be calculated.

$ npx pagespeed-score --runs 3 https://www.ft.com/
name  	score	FCP	SI	LCP	TTI	TBT	CLS
run 1 	36	6.3	7.1	7.9	10.8	0.4	0.00
run 2 	36	6.3	7.1	8.0	10.8	0.4	0.00
run 3 	36	6.3	7.3	7.9	10.8	0.4	0.00

median	36	6.3	7.1	7.9	10.8	0.4	0.00
stddev	0.0	0.0	0.1	0.0	0.0	0.0	0.00
min   	36	6.3	7.1	7.9	10.8	0.4	0.00
max   	36	6.3	7.3	8.0	10.8	0.4	0.00

mobile or desktop strategy

--strategy <mobile|desktop> sets the Lighthouse strategy (default: mobile)

$ npx pagespeed-score --strategy desktop https://www.google.com
name  	score	FCP	FMP	SI	FCI	TTI
run 1 	100	0.5	0.5	0.5	0.9	0.9

save result JSON to disk

--save-results will save all Lighthouse results (from the PSI API response or local Lighthouse run) as JSON files.

$ npx pagespeed-score --save-results --runs=2 https://www.google.com
name  	score	FCP	FMP	SI	FCI	TTI
run 1 	96	0.9	1.0	1.2	3.1	3.9
run 2 	96	0.9	1.0	1.0	3.1	3.7

$ ls
1-0.result.json
2-0.result.json

Local mode

Switches to running Lighthouse locally instead of calling the PSI API. This can be useful for non-public URLs (e.g. staging environment on a private network) or debugging. To ensure the local results are close to the PSI API results this module:

  • uses the same version of LightHouse as PSI (6.0.0 as of 2020-05-30)
  • uses the LightRider mobile config like PSI
  • allows throttling of CPU to better match PSI infrastructure limits
  • you can also use the same Chrome version as PSI (81 as of 2020-05-30) by specifying CHROME_PATH (and ensuring you have the correct version installed)
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" npx pagespeed-score --local "<url>"

Local results will still differ from the PSI API because of local hardware and network variability.

set CPU slowdown multiplier

--cpu-slowdown will allow setting CPU throttling multiplier (default 4x). Only available in local mode.

Please note that PSI infrastructure already runs on a slower CPU (that's like a mobile device) hence the need to slow our machines CPU down for local runs.

save trace & devtools log to disk

--save-assets will save trace & devtools log to disk. Only available in local mode.

$ npx pagespeed-score --save-assets --local https://www.google.com
name  	score	FCP	FMP	SI	FCI	TTI
run 1 	95	1.4	1.4	1.7	3.6	3.8

$ ls
1-0.devtoolslog.json
1-0.trace.json

save Lantern metrics estimation traces

Setting the LANTERN_DEBUG=true environment variable along with --save-assets --local will save traces for how metrics were simulated by Lantern. Only available in local mode.

$ LANTERN_DEBUG=true npx pagespeed-score --local --save-assets https://www.google.com
name  	score	FCP	FMP	SI	FCI	TTI
run 1 	95	1.4	1.4	1.7	3.6	3.8

$ ls
1-0.devtoolslog.json
1-0.trace.json
1-optimisticFirstContentfulPaint.trace.json
1-optimisticFirstMeaningfulPaint.trace.json
1-optimisticFlexFirstContentfulPaint.trace.json
1-optimisticFlexFirstMeaningfulPaint.trace.json
1-optimisticFlexInteractive.trace.json
1-optimisticInteractive.trace.json
1-pessimisticFirstContentfulPaint.trace.json
1-pessimisticFirstMeaningfulPaint.trace.json
1-pessimisticInteractive.trace.json

You can drag and drop these traces on the Chrome Devtools Performance tab.

See also lighthouse#5844 Better visualization of Lantern simulation.

Package Sidebar

Install

npm i pagespeed-score

Weekly Downloads

6

Version

1.2.7

License

MIT

Unpacked Size

15.6 kB

Total Files

12

Last publish

Collaborators

  • csabapalfi