Run chrome lighthouse's audit from command line

Viewed 8561

I would like to write a script which run (from the chrome's binary) its lighthouse's audit with a url given. I didn't manage to find how to do it, but since there is even a chrome extension doing I assume it should be feasible right ?

2 Answers

You can use/test via npx:

npm i npx -g

Then, directly run from your terminal without using a package.json created or installing globally & without opening a chrome browser instance:

npx lighthouse <URL> --only-categories="performance,seo,Accessibility" --chrome-flags="--headless"
Related