Skip to content

Commit f7aa79a

Browse files
authored
Merge pull request #1 from dvelasquez/feat/lighthouse-v7
feat(lighthouse-v7)
2 parents 3b548cf + 092f6eb commit f7aa79a

23 files changed

Lines changed: 280 additions & 15083 deletions

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: CI
2+
on: push
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Use node 12
9+
uses: actions/setup-node@v1
10+
with:
11+
node-version: '12.x'
12+
- name: Install, link plugin locally, and run
13+
run: |
14+
yarn install
15+
yarn link
16+
yarn link lighthouse-plugin-crux

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,4 @@ fabric.properties
192192
latest-run
193193
.idea
194194
lib
195+
results

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
assets
2+
.idea
3+
.github
4+
latest-run
5+
node_modules
6+
src
7+
!lib

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2012-2020 Danilo Velásquez
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# lighthouse-plugin-crux
2+
3+
> A Lighthouse plugin that displays the field performance of your page.
4+
> It uses real-world data from Chrome UX Report and Core Web Vitals to estimate the score.
5+
6+
[An example report for github.com/GoogleChrome/lighthouse](https://googlechrome.github.io/lighthouse/viewer/?gist=cb20232dcc7a8b4e93d63ae3b09ac47e):
7+
8+
![An image with the result of an execution using the lighthouse-plugin-crux](./assets/plugin-result.jpg "Lighthouse Plugin CrUX")
9+
10+
This plugin adds Core Web Vitals values to your Lighthouse report. The CrUX Performance category includes real-user data
11+
provided by [Chrome UX Report](https://developers.google.com/web/tools/chrome-user-experience-report/). It's similar to
12+
the field section in [PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights/) but it uses the Chrome
13+
User Experience Report API instead of the PageSpeed Insights API. This API is faster than the PSI API since it doesn't
14+
need run a full lighthouse run to give the results.
15+
16+
The scoring algorithm weighs values for Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout
17+
Shift (CLS) and picks a **minimum score**. It uses Core Web Vitals assessment that expects all its metrics to pass
18+
thresholds. For example, https://edition.cnn.com/ has LCP 5.9 s (15), FID 20 ms (100), and CLS 0.02 (100). It has
19+
`poor` mark in the [Search Console](https://support.google.com/webmasters/answer/9205520), and the score is 15.
20+
(_Note_: FCP and the origin values do not affect the score, [see the source](./src/plugin.ts))
21+
22+
Check out the parity between Field & Lab performance on mobile:
23+
24+
<img width="973" alt="Field & lab performance on mobile" src="https://user-images.githubusercontent.com/158189/83353215-31b75b80-a351-11ea-801e-07f5a2b73e51.png">
25+
26+
And on desktop:
27+
28+
<img width="972" alt="Field & lab performance on desktop" src="https://user-images.githubusercontent.com/158189/83353212-2ebc6b00-a351-11ea-9cf8-6a04a5f0f903.png">
29+
30+
Sometimes field data is missing because a URL doesn't have enough anonymous traffic. In this case, the lab data is the only available measurement.
31+
32+
## Install
33+
34+
Requires Node.js `12+` and Lighthouse `7+`.
35+
36+
```bash
37+
$ npm install lighthouse lighthouse-plugin-crux
38+
```
39+
40+
## Usage
41+
42+
Use the plugin with [Lighthouse CLI](https://github.com/GoogleChrome/lighthouse):
43+
44+
```bash
45+
$ npx lighthouse https://www.apple.com/ --plugins=lighthouse-plugin-crux
46+
```
47+
48+
Provide your [Chrome User Experience Report token](https://developers.google.com/web/tools/chrome-user-experience-report/api/guides/getting-started) to run more requests (in production) with a custom config:
49+
50+
```bash
51+
$ npx lighthouse https://www.apple.com/ --config-path=./config.js
52+
```
53+
54+
`config.js`
55+
56+
```js
57+
module.exports = {
58+
extends: 'lighthouse:default',
59+
plugins: ['lighthouse-plugin-crux'],
60+
settings: {
61+
cruxToken: 'YOUR_REAL_TOKEN',
62+
},
63+
}
64+
```
65+
66+
## Credits
67+
68+
Heavily based on the [lighthouse-plugin-field-data](https://github.com/treosh/lighthouse-plugin-field-performance)
69+
70+
[![](https://img.shields.io/npm/v/lighthouse-plugin-crux.svg)](https://npmjs.org/package/lighthouse-plugin-crux)
71+
[![](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)

assets/plugin-result.jpg

238 KB
Loading

0 commit comments

Comments
 (0)