Automated auditing, performance metrics, and best practices for the web.
Перейти к файлу
Rob Dodson 48296c85e6 core(config): Re-weight a11y scores based on severity and frequency (#3515) 2017-10-10 18:27:09 -07:00
assets Add lh-canary logo to assets 2017-05-05 15:33:32 -07:00
chrome-launcher Switch to using standalone chrome-launcher package (#3410) 2017-09-26 07:14:08 +09:00
docs docs(bug-labels.md): Updating bug labels (#3525) 2017-10-10 16:55:50 -07:00
lighthouse-cli test(smokehouse): Passive event listener violation doesn't report on passive:false now (#3498) 2017-10-06 15:42:16 -07:00
lighthouse-core core(config): Re-weight a11y scores based on severity and frequency (#3515) 2017-10-10 18:27:09 -07:00
lighthouse-extension web-inspector: fall back to page's Runtime and queryParam() (#3497) 2017-10-06 15:19:36 -07:00
lighthouse-logger fix(eslint): Enable trailing commas rule in ESLint, fix all errors (#3324) 2017-09-19 17:48:22 -07:00
lighthouse-viewer fix(eslint): Enable trailing commas rule in ESLint, fix all errors (#3324) 2017-09-19 17:48:22 -07:00
plots Switch to using standalone chrome-launcher package (#3410) 2017-09-26 07:14:08 +09:00
third-party/snyk feat(audit): No vulnerable JS libraries audit (#2372) 2017-09-29 15:53:49 -07:00
typings update jsconfig for intellisense. 2016-12-16 00:27:07 -08:00
.appveyor.yml Appveyor fixes: fresh yarn, only node6 build (#2382) 2017-05-29 22:27:14 -07:00
.codecov.yml tweak codecov config. 2017-07-05 08:55:10 -07:00
.editorconfig editorconfig 2016-03-09 23:42:40 -08:00
.eslintignore Switch to using standalone chrome-launcher package (#3410) 2017-09-26 07:14:08 +09:00
.eslintrc.js fix(eslint): Enable trailing commas rule in ESLint, fix all errors (#3324) 2017-09-19 17:48:22 -07:00
.gitattributes Added Windows 10 without Chrome Canary support (#690) 2016-09-22 03:10:17 -07:00
.gitignore chore: remove perfX (#3431) 2017-09-28 13:18:07 -07:00
.npmignore fix(npm): remove lighthouse-logger/ from npm package (#3411) 2017-09-26 07:17:34 -07:00
.travis.yml Switch to using standalone chrome-launcher package (#3410) 2017-09-26 07:14:08 +09:00
AUTHORS authors file. 2016-03-02 15:42:48 -05:00
CONTRIBUTING.md fixing some grammatical errors (#3419) 2017-09-26 19:29:39 -07:00
LICENSE Adds tests. 2016-01-15 17:13:20 +00:00
changelog.md web-inspector: fall back to page's Runtime and queryParam() (#3497) 2017-10-06 15:19:36 -07:00
jsconfig.json remove report v1 and dependencies (#2596) 2017-06-28 14:07:42 -07:00
package.json tests(eslint): use --quiet flag rather than --silent (#3491) 2017-10-06 18:31:53 -07:00
readme.md docs(readme): add Treo to the list of integrations (#3484) 2017-10-06 17:31:17 -07:00
yarn.lock Bump launcher to 0.8.1 (#3479) 2017-10-05 08:26:33 -07:00

readme.md

Lighthouse Linux Build Status Windows Build Status Coverage Status NPM lighthouse package

Lighthouse analyzes web apps and web pages, collecting modern performance metrics and insights on developer best practices.

Using Lighthouse in Chrome DevTools

Lighthouse is integrated directly into the Chrome Developer Tools, under the "Audits" panel.

Installation: install Chrome.

Run it: open Chrome DevTools, select the Audits panel, and hit "Perform an Audit...".

Lighthouse integration in Chrome DevTools

Using the Chrome extension

Installation: install the extension from the Chrome Web Store.

Run it: follow the extension quick-start guide.

Using the Node CLI

Lighthouse requires Node 6 or later.

Installation:

npm install -g lighthouse
# or use yarn:
# yarn global add lighthouse

Run it: lighthouse https://airhorner.com/

By default, Lighthouse writes the report to an HTML file. You can control the output format by passing flags.

CLI options

$ lighthouse --help

lighthouse <url>

Logging:
  --verbose  Displays verbose logging                                                                                                      [boolean]
  --quiet    Displays no progress, debug logs or errors                                                                                    [boolean]

Configuration:
  --save-assets                  Save the trace contents & screenshots to disk                                                             [boolean]
  --save-artifacts               Save all gathered artifacts to disk                                                                       [boolean]
  --list-all-audits              Prints a list of all available audits and exits                                                           [boolean]
  --list-trace-categories        Prints a list of all required trace categories and exits                                                  [boolean]
  --additional-trace-categories  Additional categories to capture with the trace (comma-delimited).
  --config-path                  The path to the config JSON.
  --chrome-flags                 Custom flags to pass to Chrome (space-delimited). For a full list of flags, see
                                 http://peter.sh/experiments/chromium-command-line-switches/.

                                 Environment variables:
                                 CHROME_PATH: Explicit path of intended Chrome binary. If set must point to an executable of a build of
                                 Chromium version 54.0 or later. By default, any detected Chrome Canary or Chrome (stable) will be launched.
                                                                                                                                       [default: ""]
  --perf                         Use a performance-test-only configuration                                                                 [boolean]
  --port                         The port to use for the debugging protocol. Use 0 for a random port                                 [default: 9222]
  --hostname                     The hostname to use for the debugging protocol.                                                [default: localhost]
  --max-wait-for-load            The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue.
                                 WARNING: Very high values can lead to large traces and instability                                 [default: 25000]

Output:
  --output       Reporter for the results, supports multiple values                           [choices: "json", "html", "domhtml"] [default: "html"]
  --output-path  The file path to output the results. Use 'stdout' to write to stdout.
                 If using JSON output, default is stdout.
                 If using HTML output, default is a file in the working directory with a name based on the test URL and date.
                 If using multiple outputs, --output-path is ignored.
                 Example: --output-path=./lighthouse-results.html
  --view         Open HTML report in your browser                                                                                          [boolean]

Options:
  --help                        Show help                                                                                                  [boolean]
  --version                     Show version number                                                                                        [boolean]
  --blocked-url-patterns        Block any network requests to the specified URL patterns                                                     [array]
  --disable-storage-reset       Disable clearing the browser cache and other storage APIs before a run                                     [boolean]
  --disable-device-emulation    Disable Nexus 5X emulation                                                                                 [boolean]
  --disable-cpu-throttling      Disable CPU throttling                                                                    [boolean] [default: false]
  --disable-network-throttling  Disable network throttling                                                                                 [boolean]

Examples:
  lighthouse <url> --view                                                   Opens the HTML report in a browser after the run completes
  lighthouse <url> --config-path=./myconfig.js                              Runs Lighthouse with your own configuration: custom audits, report
                                                                            generation, etc.
  lighthouse <url> --output=json --output-path=./report.json --save-assets  Save trace, screenshots, and named JSON report.
  lighthouse <url> --disable-device-emulation --disable-network-throttling  Disable device emulation
  lighthouse <url> --chrome-flags="--window-size=412,732"                   Launch Chrome with a specific window size
  lighthouse <url> --quiet --chrome-flags="--headless"                      Launch Headless Chrome, turn off logging

For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.


Output Examples

lighthouse generates

  • ./<HOST>_<DATE>.report.html

lighthouse --output json generates

  • json output on stdout

lighthouse --output html --output-path ./report.html generates

  • ./report.html

NOTE: specifying an output path with multiple formats ignores your specified extension for ALL formats

lighthouse --output json --output html --output-path ./myfile.json generates

  • ./myfile.report.json
  • ./myfile.report.html

lighthouse --output json --output html generates

  • ./<HOST>_<DATE>.report.json
  • ./<HOST>_<DATE>.report.html

lighthouse --output-path=~/mydir/foo.out --save-assets generates

  • ~/mydir/foo.report.html
  • ~/mydir/foo-0.trace.json
  • ~/mydir/foo-0.screenshots.html

lighthouse --output-path=./report.json --output json --save-artifacts generates

  • ./report.json
  • ./report.artifacts.log

lighthouse --save-artifacts generates

  • ./<HOST>_<DATE>.report.html
  • ./<HOST>_<DATE>.artifacts.log

Viewing a report

Lighthouse can produce a report as JSON or HTML.

HTML report:

Lighthouse report

Online Viewer

Running Lighthouse with the --output=json flag generates a json dump of the run. You can view this report online by visiting https://googlechrome.github.io/lighthouse/viewer/ and dragging the file onto the app. You can also use the "Export" button from the top of any Lighthouse HTML report and open the report in the Lighthouse Viewer.

In the Viewer, reports can be shared by clicking the share icon in the top right corner and signing in to GitHub.

Note: shared reports are stashed as a secret Gist in GitHub, under your account.

Docs & Recipes

Useful documentation, examples, and recipes to get you started.

Docs

Recipes

Videos

The session from Google I/O 2017 covers architecture, writing custom audits, Github/Travis/CI integration, headless Chrome, and more:

Lighthouse @ Google I/O

click to watch the video

Develop

Read on for the basics of hacking on Lighthouse. Also see Contributing for detailed information.

Setup

# yarn should be installed first

git clone https://github.com/GoogleChrome/lighthouse

cd lighthouse
yarn
yarn install-all
yarn build-all

# The CLI is authored in TypeScript and requires compilation.
# If you need to make changes to the CLI, run the TS compiler in watch mode:
# cd lighthouse-cli && yarn dev

Run

node lighthouse-cli http://example.com

Getting started tip: node --inspect --debug-brk lighthouse-cli http://example.com to open up Chrome DevTools and step through the entire app. See Debugging Node.js with Chrome DevTools for more info.

Tests

# lint and test all files
yarn test

# watch for file changes and run tests
#   Requires http://entrproject.org : brew install entr
yarn watch

## run linting, unit, and smoke tests separately
yarn lint
yarn unit
yarn smoke

## run closure compiler (on whitelisted files)
yarn closure
## import your report renderer into devtools-frontend and run devtools closure compiler
yarn compile-devtools

Lighthouse Integrations

This section details projects that have integrated Lighthouse. If you're working on a cool project integrating Lighthouse and would like to be featured here, file an issue to this repo or tweet at us @_____lighthouse

  • Calibre - Calibre is a web performance monitoring tool running Lighthouse continuously or on-demand via an API. Test using emulated devices and connection speeds from a number of geographical locations. Set budgets and improve performance with actionable guidelines. Note that Calibre is a paid product with a free 14-day trial.

  • Treo - Treo is Lighthouse as a Service. It provides regression testing, geographical regions, custom networks, and integrations with Github & Slack. Treo is a paid product with plans for solo-developers and teams.

  • Web Page Test — An open source tool for measuring and analyzing the performance of web pages on real devices. Users can choose to produce a Lighthouse report alongside the analysis of WebPageTest results.

FAQ

How does Lighthouse work?

See Lighthouse Architecture.

Can I configure the lighthouse run?

Yes! Details in Lighthouse configuration.

How does Lighthouse use network throttling, and how can I make it better?

Good question. Network and CPU throttling are applied by default in a Lighthouse run. The network attempts to emulate 3G and the CPU is slowed down 4x from your machine's default speed. If you prefer to run Lighthouse without throttling, you'll have to use the CLI and disable it with the --disable-* flags mentioned above.

Read more in our guide to network throttling.

Are results sent to a remote server?

Nope. Lighthouse runs locally, auditing a page using a local version of the Chrome browser installed the machine. Report results are never processed or beaconed to a remote server.

How do I author custom audits to extend Lighthouse?

Tip: see Lighthouse Architecture for more information on terminology and architecture.

Lighthouse can be extended to run custom audits and gatherers that you author. This is great if you're already tracking performance metrics in your site and want to surface those metrics within a Lighthouse report.

If you're interested in running your own custom audits, check out our Custom Audit Example over in recipes.

How do I contribute?

We'd love help writing audits, fixing bugs, and making the tool more useful! See Contributing to get started.


Lighthouse logo
Lighthouse, ˈlītˌhous (n): a tower or other structure tool containing a beacon light to warn or guide ships at sea developers.