Skip to content

Commit e410b34

Browse files
authored
docs: update docs for v3 (GoogleChrome#5357)
1 parent 8f500e0 commit e410b34

12 files changed

+168
-185
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We'd love your help! This doc covers how to become a contributor and submit code
44

55
## Follow the coding style
66

7-
The `.eslintrc` file defines all. We use [JSDoc](http://usejsdoc.org/) along with [closure annotations](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler). Annotations are encouraged for all contributions.
7+
The `.eslintrc` file defines all. We use [JSDoc](http://usejsdoc.org/) with [TypeScript](https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript). Annotations are encouraged for all contributions.
88

99
## Pull request titles
1010

docs/architecture.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ Tracing processor takes the output of trace of tab and identifies the top-level
8484

8585
## Audits
8686

87-
The return value of each audit [takes this shape](https://github.com/GoogleChrome/lighthouse/blob/b354890076f2c077c5460b2fa56ded546cca72ee/lighthouse-core/closure/typedefs/AuditResult.js#L23-L55).
87+
The return value of each audit [takes this shape](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/typings/audit.d.ts#L117-L130).
8888

8989
The `details` object is parsed in report-renderer.js. View other audits for guidance on how to structure `details`.

docs/configuration.md

+24-27
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,16 @@ You can specify a custom config file when using Lighthouse through the CLI or co
1111
**custom-config.js**
1212
```js
1313
module.exports = {
14-
passes: [{
15-
recordTrace: true,
16-
pauseAfterLoadMs: 5000,
17-
useThrottling: true,
18-
gatherers: [],
19-
}],
20-
21-
audits: [
22-
'first-meaningful-paint',
23-
'speed-index-metric',
24-
'estimated-input-latency',
25-
'first-interactive',
26-
'consistently-interactive',
27-
]
14+
extends: 'lighthouse:default',
15+
settings: {
16+
onlyAudits: [
17+
'first-meaningful-paint',
18+
'speed-index-metric',
19+
'estimated-input-latency',
20+
'first-interactive',
21+
'consistently-interactive',
22+
],
23+
},
2824
};
2925
```
3026

@@ -77,6 +73,8 @@ The settings property controls various aspects of running Lighthouse such as CPU
7773
```
7874

7975
#### Options
76+
For full list see [our default config settings](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/lighthouse-core/config/constants.js#L30-L48).
77+
8078
| Name | Type | Description |
8179
| -- | -- | -- |
8280
| onlyCategories | `string[]` | Includes only the specified categories in the final report. Additive with `onlyAudits` and reduces the time to audit a page. |
@@ -89,22 +87,21 @@ The passes property controls how to load the requested URL and what information
8987

9088
Each `passes` entry defines basic settings such as how long to wait for the page to load and whether to record a trace file. Additionally a list of **gatherers** to use is defined per pass. Gatherers can read information from the page to generate artifacts which are later used by audits to provide you with a Lighthouse report. For more information on implementing a custom gatherer and the role they play in building a Lighthouse report, refer to the [recipes](https://github.com/GoogleChrome/lighthouse/blob/master/docs/recipes/custom-audit). Also note that `artifacts.devtoolsLogs` will be automatically populated for every pass. Gatherers also have access to this data within the `afterPass` as `traceData.devtoolsLog` (However, most will find the higher-level `traceData.networkRecords` more useful).
9189

90+
For list of default pass values, see [our config constants](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/lighthouse-core/config/constants.js#L50-L61).
9291

9392
#### Example
9493
```js
9594
{
9695
passes: [
9796
{
9897
passName: 'fastPass',
99-
recordTrace: true,
100-
useThrottling: false,
101-
networkQuietThresholdMs: 0,
10298
gatherers: ['fast-gatherer'],
10399
},
104100
{
105101
passName: 'slowPass',
106102
recordTrace: true,
107103
useThrottling: true,
104+
networkQuietThresholdMs: 5000,
108105
gatherers: ['slow-gatherer'],
109106
}
110107
]
@@ -141,7 +138,7 @@ The audits property controls which audits to run and include with your Lighthous
141138

142139
### `categories: Object|undefined`
143140

144-
The categories property controls how to score and organize the audit results in the report. Each category defined in the config will have an entry in the `reportCategories` property of Lighthouse's output. The category output contains the child audit results along with an overall score for the category.
141+
The categories property controls how to score and organize the audit results in the report. Each category defined in the config will have an entry in the `categories` property of Lighthouse's output. The category output contains the child audit results along with an overall score for the category.
145142

146143
**Note:** many modules consuming Lighthouse have no need to group or score all the audit results; in these cases, it's fine to omit a categories section.
147144

@@ -150,9 +147,9 @@ The categories property controls how to score and organize the audit results in
150147
{
151148
categories: {
152149
performance: {
153-
name: 'Performance',
150+
title: 'Performance',
154151
description: 'This category judges your performance',
155-
audits: [
152+
auditRefs: [
156153
{id: 'first-meaningful-paint', weight: 2, group: 'metrics'},
157154
{id: 'first-interactive', weight: 3, group: 'metrics'},
158155
{id: 'consistently-interactive', weight: 5, group: 'metrics'},
@@ -165,12 +162,12 @@ The categories property controls how to score and organize the audit results in
165162
#### Options
166163
| Name | Type | Description |
167164
| -- | -- | -- |
168-
| name | `string` | The display name of the category. |
165+
| title | `string` | The display name of the category. |
169166
| description | `string` | The displayed description of the category. |
170-
| audits | `Object[]` | The audits to include in the category. |
171-
| audits[$i].id | `string` | The ID of the audit to include. |
172-
| audits[$i].weight | `number` | The weight of the audit in the scoring of the category. |
173-
| audits[$i].group | `string` (optional) | The ID of the [display group](#groups-objectundefined) of the audit. |
167+
| auditRefs | `Object[]` | The audits to include in the category. |
168+
| auditRefs[$i].id | `string` | The ID of the audit to include. |
169+
| auditRefs[$i].weight | `number` | The weight of the audit in the scoring of the category. |
170+
| auditRefs[$i].group | `string` (optional) | The ID of the [display group](#groups-objectundefined) of the audit. |
174171

175172
### `groups: Object|undefined`
176173

@@ -183,7 +180,7 @@ The groups property controls how to visually group audits within a category. For
183180
{
184181
categories: {
185182
performance: {
186-
audits: [
183+
auditRefs: [
187184
{id: 'my-performance-metric', weight: 2, group: 'metrics'},
188185
],
189186
}
@@ -208,7 +205,7 @@ The stock Lighthouse configurations can be extended if you only need to make sma
208205
The best examples are the ones Lighthouse uses itself! There are several reference configuration files that are maintained as part of Lighthouse.
209206

210207
* [lighthouse-core/config/default-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/default-config.js)
211-
* [lighthouse-core/config/plots-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/plots-config.js)
208+
* [lighthouse-core/config/perf-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/perf-config.js)
212209
* [docs/recipes/custom-audit/custom-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/docs/recipes/custom-audit/custom-config.js)
213210
* [pwmetrics](https://github.com/paulirish/pwmetrics/blob/master/lib/lh-config.ts)
214211

docs/headless-chrome.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ lighthouse --chrome-flags="--headless" https://github.com
2727
Alternatively, you can run full Chrome + xvfb instead of headless mode. These steps worked on Debian Jessie:
2828

2929
```sh
30-
# get node 6
31-
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
30+
# get node 8
31+
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
3232
sudo apt-get install -y nodejs
3333

3434
# get chromium (stable) and Xvfb

docs/lantern.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Stats were collected using the [trace-evaluation](https://github.com/patrickhulc
2929
We conclude that Lantern is ~6-13% more inaccurate than DevTools throttling. When evaluating rank performance, Lantern achieves correlations within ~.04-.07 of DevTools throttling.
3030

3131
* For the single view use case, our original conclusion that Lantern's inaccuracy is roughly equal to the inaccuracy introduced by expected variance seems to hold. The standard deviation of single observations from DevTools throttling is ~9-13%, and given Lantern's much lower variance, single observations from Lantern are not significantly more inaccurate on average than single observations from DevTools throttling.
32-
* For the repeat view use case, we can conclude that Lantern is systematically off by ~6-13% more than DevTools throttling.
32+
* For the repeat view use case, we can conclude that Lantern is systematically off by ~6-13% more than DevTools throttling.
3333

3434
### Metric Variability Conclusions
3535
The reference stats demonstrate that there is high degree of variability with the user-centric metrics and strengthens the position that every load is just an observation of a point drawn from a distribution and to understand the entire experience, multiple draws must be taken, i.e. multiple runs are needed to have sufficiently small error bounds on the median load experience.

docs/puppeteer.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ browser.on('targetchanged', async target => {
4545

4646
// Lighthouse will open URL. Puppeteer observes `targetchanged` and sets up network conditions.
4747
// Possible race condition.
48-
const lhr = await lighthouse(url, {
48+
const {lhr} = await lighthouse(url, {
4949
port: (new URL(browser.wsEndpoint())).port,
5050
output: 'json',
5151
logLevel: 'info',
5252
});
5353

54-
console.log(`Lighthouse scores: ${lhr.reportCategories.map(c => c.score).join(', ')}`);
54+
console.log(`Lighthouse scores: ${Object.values(lhr.categories).map(c => c.score).join(', ')}`);
5555

5656
await browser.close();
5757
})();
@@ -89,8 +89,8 @@ const {webSocketDebuggerUrl} = JSON.parse(resp.body);
8989
const browser = await puppeteer.connect({browserWSEndpoint: webSocketDebuggerUrl});
9090

9191
// Run Lighthouse.
92-
const lhr = await lighthouse(URL, opts, null);
93-
console.log(`Lighthouse scores: ${lhr.reportCategories.map(c => c.score).join(', ')}`);
92+
const {lhr} = await lighthouse(URL, opts, null);
93+
console.log(`Lighthouse scores: ${Object.values(lhr.categories).map(c => c.score).join(', ')}`);
9494

9595
await browser.disconnect();
9696
await chrome.kill();

docs/readme.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ function launchChromeAndRunLighthouse(url, opts, config = null) {
1515
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => {
1616
opts.port = chrome.port;
1717
return lighthouse(url, opts, config).then(results => {
18-
// The gathered artifacts are typically removed as they can be quite large (~50MB+)
19-
delete results.artifacts;
20-
return chrome.kill().then(() => results)
18+
// use results.lhr for the JS-consumeable output
19+
// https://github.com/GoogleChrome/lighthouse/blob/master/typings/lhr.d.ts
20+
// use results.report for the HTML/JSON/CSV output as a string
21+
// use results.artifacts for the trace/screenshots/other specific case you need (rarer)
22+
return chrome.kill().then(() => results.lhr)
2123
});
2224
});
2325
}
@@ -39,13 +41,31 @@ Many modules consuming Lighthouse are only interested in the performance numbers
3941
You can limit the audits you run to a particular category or set of audits.
4042

4143
```js
42-
const perfConfig = require('lighthouse/lighthouse-core/config/perf-config.js');
4344
// ...
44-
launchChromeAndRunLighthouse(url, flags, perfConfig).then( // ...
45+
const flags = {onlyCategories: ['performance']};
46+
launchChromeAndRunLighthouse(url, flags).then( // ...
4547
```
4648
4749
You can also craft your own config (e.g. [mixed-content-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/mixed-content-config.js)) for custom runs. Also see the [basic custom audit recipe](https://github.com/GoogleChrome/lighthouse/tree/master/docs/recipes/custom-audit).
4850
51+
### Differences from CLI flags
52+
53+
Note that some flag functionality is only available to the CLI. The set of shared flags that work in both node and CLI can be found [in our typedefs](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/typings/externs.d.ts#L68). In most cases, the functionality is not offered in the node module simply because it is easier and more flexible to do it yourself.
54+
55+
| CLI Flag | Differences in Node |
56+
| - | - |
57+
| `port` | Only specifies which port to use, Chrome is not launched for you. |
58+
| `chromeFlags` | Ignored, Chrome is not launched for you. |
59+
| `outputPath` | Ignored, output is returned as string in `.report` property. |
60+
| `saveAssets` | Ignored, artifacts are returned in `.artifacts` property. |
61+
| `view` | Ignored, use the `opn` npm module if you want this functionality. |
62+
| `enableErrorReporting` | Ignored, error reporting is always disabled for node. |
63+
| `listAllAudits` | Ignored, not relevant in programmatic use. |
64+
| `listTraceCategories` | Ignored, not relevant in programmatic use. |
65+
| `configPath` | Ignored, pass the config in as the 3rd argument to `lighthouse`. |
66+
| `preset` | Ignored, pass the config in as the 3rd argument to `lighthouse`. |
67+
| `verbose` | Ignored, use `logLevel` instead. |
68+
| `quiet` | Ignored, use `logLevel` instead. |
4969
5070
### Turn on logging
5171
@@ -56,7 +76,7 @@ the `logLevel` flag when calling `lighthouse`.
5676
```javascript
5777
const log = require('lighthouse-logger');
5878

59-
const flags = {logLevel: 'info', output: 'json'};
79+
const flags = {logLevel: 'info'};
6080
log.setLevel(flags.logLevel);
6181

6282
launchChromeAndRunLighthouse('https://example.com', flags).then(...);

docs/scoring.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Note 1: if you want a **nice spreadsheet** version of this doc to understand wei
66
![alt text](https://user-images.githubusercontent.com/39191/32397461-2d20c87a-c0a7-11e7-99d8-61576113a710.png)
77
*Screenshot of the [scoring spreadsheet](https://docs.google.com/spreadsheets/d/1Cxzhy5ecqJCucdf1M0iOzM8mIxNc7mmx107o5nj38Eo/edit#gid=0)*
88

9-
Note 2: if you receive a **score of 0** in any Lighthouse category, that usually indicates an error on our part. Please file an [issue](https://github.com/GoogleChrome/lighthouse/issues) so our team can look into it.
9+
Note 2: receiving a **score of ?** in any Lighthouse category indicates an error occurred. Please file an [issue](https://github.com/GoogleChrome/lighthouse/issues) so our team can look into it.
1010

1111
# Performance
1212

@@ -30,11 +30,12 @@ The performance score is determined from the **performance metrics only**. The O
3030

3131
The metric results are not weighted equally. Currently the weights are:
3232

33-
* 5X - first meaningful paint
34-
* 5X - first interactive
33+
* 3X - first contentful paint
34+
* 1X - first meaningful paint
35+
* 3X - first cpu idle
3536
* 5X - consistently interactive
36-
* 1X - perceptual speed index
37-
* 1X - estimated input latency
37+
* 4X - speed index
38+
* 0X - estimated input latency
3839

3940
These weights are heuristics, and the Lighthouse team is working on formalizing the weighting system through more field data.
4041

@@ -47,7 +48,7 @@ Once we finish computing the percentile equivalent of your raw performance score
4748
- Green (good): 75-100.
4849

4950
### What can developers do to improve their performance score?
50-
*Note: we've built [a little calculator](https://docs.google.com/spreadsheets/d/1dXH-bXX3gxqqpD1f7rp6ImSOhobsT1gn_GQ2fGZp8UU/edit?ts=59fb61d2#gid=283330180) that can help you understand what thresholds you should be aiming for achieving a certain Lighthouse performance score. *
51+
*Note: we've built [a little calculator](https://docs.google.com/spreadsheets/d/1Cxzhy5ecqJCucdf1M0iOzM8mIxNc7mmx107o5nj38Eo/edit#gid=283330180) that can help you understand what thresholds you should be aiming for achieving a certain Lighthouse performance score. *
5152

5253
Lighthouse has a whole section in the report on improving your performance score under the “Opportunities” section. There are detailed suggestions and documentation that explains the different suggestions and how to implement them. Additionally, the diagnostics section lists additional guidance that developers can explore to further experiment and tweak with their performance.
5354

docs/throttling.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ This is the standard recommendation for 3G throttling:
77
- Throughput: 1.6Mbps down / 750 Kbps up.
88
- Packet loss: none.
99

10-
These exact figures are used as the [WebPageTest "Mobile 3G - Fast" preset](https://github.com/WPO-Foundation/webpagetest/blob/master/www/settings/connectivity.ini.sample) and [Lighthouse's throttling default](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/lib/emulation.js).
10+
These exact figures are used as the [WebPageTest "Mobile 3G - Fast" preset](https://github.com/WPO-Foundation/webpagetest/blob/master/www/settings/connectivity.ini.sample) and [Lighthouse's throttling default](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/lighthouse-core/config/constants.js#L19-L26).
1111

1212
## Throttling basics
1313

14-
1. The DevTools network throttling, which Lighthouse uses, is implemented within Chrome at the _request-level_. As a result, it has some downsides that are now summarized in this doc: [Network Throttling & Chrome - status](https://docs.google.com/document/d/1TwWLaLAfnBfbk5_ZzpGXegPapCIfyzT4MWuZgspKUAQ/edit). The TLDR: while it's a [decent approximation](https://docs.google.com/document/d/1uS9SH1KpVH31JAmf-iIZ61VazwAF9MrCVwETshBC4UQ/edit), it's not a sufficient model of a slow connection. The [multipliers used in Lighthouse](https://github.com/GoogleChrome/lighthouse/blob/3be483287a530fb560c843b7299ef9cfe91ce1cc/lighthouse-core/lib/emulation.js#L33-L39) attempt to correct for the differences.
14+
1. Simulated throttling, which Lighthouse uses by default, is computed throttling _after a trace has been recorded_ which makes it very fast and deterministic. However, due to the imperfect nature of predicting alternate execution paths, there is inherent inaccuracy that is summarized in this doc: [Lighthouse Metric Variability and Accuracy](https://docs.google.com/document/d/1BqtL-nG53rxWOI5RO0pItSRPowZVnYJ_gBEQCJ5EeUE/edit). The TLDR: while it's roughly as accurate or better than DevTools throttling for most sites, it suffers from edge cases and a deep investigation to performance should use _Packet-level_ throttling tools.
15+
1. The DevTools network throttling, which Lighthouse uses for `throttlingMethod='devtools'`, is implemented within Chrome at the _request-level_. As a result, it has some downsides that are now summarized in this doc: [Network Throttling & Chrome - status](https://docs.google.com/document/d/1TwWLaLAfnBfbk5_ZzpGXegPapCIfyzT4MWuZgspKUAQ/edit). The TLDR: while it's a [decent approximation](https://docs.google.com/document/d/1uS9SH1KpVH31JAmf-iIZ61VazwAF9MrCVwETshBC4UQ/edit), it's not a sufficient model of a slow connection. The [multipliers used in Lighthouse](https://github.com/GoogleChrome/lighthouse/blob/3be483287a530fb560c843b7299ef9cfe91ce1cc/lighthouse-core/lib/emulation.js#L33-L39) attempt to correct for the differences.
1516
1. _Proxy-level_ throttling tools do not affect UDP data, so they're not recommended.
1617
1. _Packet-level_ throttling tools are able to make the most accurate network simulation.
1718

0 commit comments

Comments
 (0)