Linux command
lighthouse 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Audit a URL
lighthouse [https://example.com]
Output to specific file
lighthouse [https://example.com] --output-path [report.html]
Output as JSON
lighthouse [https://example.com] --output json
Audit specific categories
lighthouse [https://example.com] --only-categories=performance,accessibility
Use headless Chrome
lighthouse [https://example.com] --chrome-flags="--headless"
Set viewport
lighthouse [https://example.com] --screenEmulation.width=[1920]
说明
lighthouse is Google's automated web auditing tool. Tests performance, accessibility, best practices, SEO, and progressive web app features. Generates detailed reports with improvement recommendations. Simulates mobile devices by default. Lighthouse requires a Chrome or Chromium installation which it launches to perform audits. The tool is also available built into Chrome DevTools and as a Node.js module for programmatic use in CI pipelines.
参数
- --output _format_
- Output format (html, json, csv).
- --output-path _file_
- Path to save report.
- --only-categories _list_
- Categories to audit.
- --chrome-flags _flags_
- Chrome launch flags.
- --preset _preset_
- Audit preset (desktop, perf).
- --view
- Open report in browser.
- --quiet
- Suppress output.
- --port _PORT_
- Port to use for the debugging protocol.
- --form-factor _FACTOR_
- Emulate mobile or desktop (mobile|desktop).
- --save-assets
- Save artifacts (screenshots, trace, devtoolslogs).
- --budget-path _FILE_
- Path to a performance budget JSON file.
- --verbose
- Enable verbose logging.
FAQ
What is the lighthouse command used for?
lighthouse is Google's automated web auditing tool. Tests performance, accessibility, best practices, SEO, and progressive web app features. Generates detailed reports with improvement recommendations. Simulates mobile devices by default. Lighthouse requires a Chrome or Chromium installation which it launches to perform audits. The tool is also available built into Chrome DevTools and as a Node.js module for programmatic use in CI pipelines.
How do I run a basic lighthouse example?
Run `lighthouse [https://example.com]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --output _format_ do in lighthouse?
Output format (html, json, csv).