Skip to content

Commit 77cc782

Browse files
authored
core(scoring): apply v6 score weightings (#9949)
1 parent c93e80b commit 77cc782

File tree

7 files changed

+101
-99
lines changed

7 files changed

+101
-99
lines changed

lighthouse-cli/test/cli/__snapshots__/index-test.js.snap

+16-17
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Object {
2525
"path": "metrics/first-contentful-paint",
2626
},
2727
Object {
28-
"path": "metrics/first-meaningful-paint",
28+
"path": "metrics/largest-contentful-paint",
2929
},
3030
Object {
31-
"path": "metrics/largest-contentful-paint",
31+
"path": "metrics/first-meaningful-paint",
3232
},
3333
Object {
3434
"path": "load-fast-enough-for-pwa",
@@ -756,48 +756,47 @@ Object {
756756
Object {
757757
"group": "metrics",
758758
"id": "first-contentful-paint",
759-
"weight": 3,
759+
"weight": 15,
760760
},
761761
Object {
762762
"group": "metrics",
763-
"id": "first-meaningful-paint",
764-
"weight": 1,
763+
"id": "speed-index",
764+
"weight": 15,
765765
},
766766
Object {
767767
"group": "metrics",
768768
"id": "largest-contentful-paint",
769-
"weight": 0,
769+
"weight": 25,
770770
},
771771
Object {
772772
"group": "metrics",
773-
"id": "speed-index",
774-
"weight": 4,
773+
"id": "interactive",
774+
"weight": 15,
775775
},
776776
Object {
777777
"group": "metrics",
778-
"id": "interactive",
779-
"weight": 5,
778+
"id": "total-blocking-time",
779+
"weight": 25,
780780
},
781781
Object {
782782
"group": "metrics",
783-
"id": "first-cpu-idle",
784-
"weight": 2,
783+
"id": "cumulative-layout-shift",
784+
"weight": 5,
785785
},
786786
Object {
787-
"group": "metrics",
788-
"id": "max-potential-fid",
787+
"id": "first-cpu-idle",
789788
"weight": 0,
790789
},
791790
Object {
792-
"id": "cumulative-layout-shift",
791+
"id": "max-potential-fid",
793792
"weight": 0,
794793
},
795794
Object {
796-
"id": "estimated-input-latency",
795+
"id": "first-meaningful-paint",
797796
"weight": 0,
798797
},
799798
Object {
800-
"id": "total-blocking-time",
799+
"id": "estimated-input-latency",
801800
"weight": 0,
802801
},
803802
Object {

lighthouse-core/audits/metrics/cumulative-layout-shift.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ class CumulativeLayoutShift extends Audit {
4444
*/
4545
static get defaultOptions() {
4646
return {
47-
// TODO(paulirish): Calibrate these
48-
scorePODR: 0.05,
49-
scoreMedian: 0.4,
47+
// Calibrated to assure 0.1 gets a score of 0.9. https://web.dev/cls/#what-is-a-good-cls-score
48+
// This 0.1 target score was determined through both manual evaluation and large-scale analysis.
49+
// see https://www.desmos.com/calculator/wmcxn7zfhc
50+
scorePODR: 0.02,
51+
scoreMedian: 0.2,
5052
};
5153
}
5254

lighthouse-core/config/default-config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ const defaultConfig = {
179179
'viewport',
180180
'without-javascript',
181181
'metrics/first-contentful-paint',
182-
'metrics/first-meaningful-paint',
183182
'metrics/largest-contentful-paint',
183+
'metrics/first-meaningful-paint',
184184
'load-fast-enough-for-pwa',
185185
'metrics/speed-index',
186186
'screenshot-thumbnails',
@@ -388,16 +388,18 @@ const defaultConfig = {
388388
'performance': {
389389
title: str_(UIStrings.performanceCategoryTitle),
390390
auditRefs: [
391-
{id: 'first-contentful-paint', weight: 3, group: 'metrics'},
392-
{id: 'first-meaningful-paint', weight: 1, group: 'metrics'},
393-
{id: 'largest-contentful-paint', weight: 0, group: 'metrics'},
394-
{id: 'speed-index', weight: 4, group: 'metrics'},
395-
{id: 'interactive', weight: 5, group: 'metrics'},
396-
{id: 'first-cpu-idle', weight: 2, group: 'metrics'},
397-
{id: 'max-potential-fid', weight: 0, group: 'metrics'},
398-
{id: 'cumulative-layout-shift', weight: 0}, // intentionally left out of metrics so it won't be displayed
399-
{id: 'estimated-input-latency', weight: 0}, // intentionally left out of metrics so it won't be displayed
400-
{id: 'total-blocking-time', weight: 0}, // intentionally left out of metrics so it won't be displayed
391+
{id: 'first-contentful-paint', weight: 15, group: 'metrics'},
392+
{id: 'speed-index', weight: 15, group: 'metrics'},
393+
{id: 'largest-contentful-paint', weight: 25, group: 'metrics'},
394+
{id: 'interactive', weight: 15, group: 'metrics'},
395+
{id: 'total-blocking-time', weight: 25, group: 'metrics'},
396+
{id: 'cumulative-layout-shift', weight: 5, group: 'metrics'},
397+
// intentionally left out of metrics group so they won't be displayed
398+
{id: 'first-cpu-idle', weight: 0},
399+
{id: 'max-potential-fid', weight: 0},
400+
{id: 'first-meaningful-paint', weight: 0},
401+
{id: 'estimated-input-latency', weight: 0},
402+
401403
{id: 'render-blocking-resources', weight: 0, group: 'load-opportunities'},
402404
{id: 'uses-responsive-images', weight: 0, group: 'load-opportunities'},
403405
{id: 'offscreen-images', weight: 0, group: 'load-opportunities'},

lighthouse-core/report/html/renderer/performance-category-renderer.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ class PerformanceCategoryRenderer extends CategoryRenderer {
132132
metricAuditsEl.append(..._toggleEl.childNodes);
133133

134134
const metricAudits = category.auditRefs.filter(audit => audit.group === 'metrics');
135-
const keyMetrics = metricAudits.filter(a => a.weight >= 3);
136-
const otherMetrics = metricAudits.filter(a => a.weight < 3);
135+
136+
const keyMetrics = metricAudits.slice(0, 3);
137+
const otherMetrics = metricAudits.slice(3);
137138

138139
const metricsBoxesEl = this.dom.createChildOf(metricAuditsEl, 'div', 'lh-columns');
139140
const metricsColumn1El = this.dom.createChildOf(metricsBoxesEl, 'div', 'lh-column');

lighthouse-core/test/config/config-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('Config', () => {
8686
it('uses the default config when no config is provided', () => {
8787
const config = new Config();
8888
assert.deepStrictEqual(config.categories, origConfig.categories);
89-
assert.equal(config.audits.length, origConfig.audits.length);
89+
assert.deepStrictEqual(config.audits.map(a => a.path), origConfig.audits);
9090
});
9191

9292
it('throws when a passName is used twice', () => {

lighthouse-core/test/results/sample_v2.json

+42-43
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@
8181
"numericUnit": "millisecond",
8282
"displayValue": "4.0 s"
8383
},
84-
"first-meaningful-paint": {
85-
"id": "first-meaningful-paint",
86-
"title": "First Meaningful Paint",
87-
"description": "First Meaningful Paint measures when the primary content of a page is visible. [Learn more](https://web.dev/first-meaningful-paint).",
88-
"score": 0.51,
89-
"scoreDisplayMode": "numeric",
90-
"numericValue": 3969.136,
91-
"numericUnit": "millisecond",
92-
"displayValue": "4.0 s"
93-
},
9484
"largest-contentful-paint": {
9585
"id": "largest-contentful-paint",
9686
"title": "Largest Contentful Paint",
@@ -101,6 +91,16 @@
10191
"numericUnit": "millisecond",
10292
"displayValue": "4.9 s"
10393
},
94+
"first-meaningful-paint": {
95+
"id": "first-meaningful-paint",
96+
"title": "First Meaningful Paint",
97+
"description": "First Meaningful Paint measures when the primary content of a page is visible. [Learn more](https://web.dev/first-meaningful-paint).",
98+
"score": 0.51,
99+
"scoreDisplayMode": "numeric",
100+
"numericValue": 3969.136,
101+
"numericUnit": "millisecond",
102+
"displayValue": "4.0 s"
103+
},
104104
"load-fast-enough-for-pwa": {
105105
"id": "load-fast-enough-for-pwa",
106106
"title": "Page load is fast enough on mobile networks",
@@ -230,7 +230,7 @@
230230
"id": "cumulative-layout-shift",
231231
"title": "Cumulative Layout Shift",
232232
"description": "Cumulative Layout Shift is the sum of all layout shifts that occurred during a page's load. A layout shift is any movement an element makes once it is visible to the user. All layout shift is recorded, scored, and then aggregated into a cumulative score between 0 and 1; 0 being a perfectly stable page, and >=0.5 being a highly shifting page. [Learn more](https://web.dev/cls).",
233-
"score": 0.48,
233+
"score": 0.21,
234234
"scoreDisplayMode": "numeric",
235235
"numericValue": 0.42,
236236
"numericUnit": "unitless",
@@ -3639,49 +3639,48 @@
36393639
"auditRefs": [
36403640
{
36413641
"id": "first-contentful-paint",
3642-
"weight": 3,
3642+
"weight": 15,
36433643
"group": "metrics"
36443644
},
36453645
{
3646-
"id": "first-meaningful-paint",
3647-
"weight": 1,
3646+
"id": "speed-index",
3647+
"weight": 15,
36483648
"group": "metrics"
36493649
},
36503650
{
36513651
"id": "largest-contentful-paint",
3652-
"weight": 0,
3652+
"weight": 25,
36533653
"group": "metrics"
36543654
},
36553655
{
3656-
"id": "speed-index",
3657-
"weight": 4,
3656+
"id": "interactive",
3657+
"weight": 15,
36583658
"group": "metrics"
36593659
},
36603660
{
3661-
"id": "interactive",
3662-
"weight": 5,
3661+
"id": "total-blocking-time",
3662+
"weight": 25,
36633663
"group": "metrics"
36643664
},
36653665
{
3666-
"id": "first-cpu-idle",
3667-
"weight": 2,
3666+
"id": "cumulative-layout-shift",
3667+
"weight": 5,
36683668
"group": "metrics"
36693669
},
36703670
{
3671-
"id": "max-potential-fid",
3672-
"weight": 0,
3673-
"group": "metrics"
3671+
"id": "first-cpu-idle",
3672+
"weight": 0
36743673
},
36753674
{
3676-
"id": "cumulative-layout-shift",
3675+
"id": "max-potential-fid",
36773676
"weight": 0
36783677
},
36793678
{
3680-
"id": "estimated-input-latency",
3679+
"id": "first-meaningful-paint",
36813680
"weight": 0
36823681
},
36833682
{
3684-
"id": "total-blocking-time",
3683+
"id": "estimated-input-latency",
36853684
"weight": 0
36863685
},
36873686
{
@@ -3853,7 +3852,7 @@
38533852
}
38543853
],
38553854
"id": "performance",
3856-
"score": 0.69
3855+
"score": 0.64
38573856
},
38583857
"accessibility": {
38593858
"title": "Accessibility",
@@ -4525,25 +4524,25 @@
45254524
},
45264525
{
45274526
"startTime": 0,
4528-
"name": "lh:audit:first-meaningful-paint",
4527+
"name": "lh:audit:largest-contentful-paint",
45294528
"duration": 100,
45304529
"entryType": "measure"
45314530
},
45324531
{
45334532
"startTime": 0,
4534-
"name": "lh:computed:FirstMeaningfulPaint",
4533+
"name": "lh:computed:LargestContentfulPaint",
45354534
"duration": 100,
45364535
"entryType": "measure"
45374536
},
45384537
{
45394538
"startTime": 0,
4540-
"name": "lh:audit:largest-contentful-paint",
4539+
"name": "lh:audit:first-meaningful-paint",
45414540
"duration": 100,
45424541
"entryType": "measure"
45434542
},
45444543
{
45454544
"startTime": 0,
4546-
"name": "lh:computed:LargestContentfulPaint",
4545+
"name": "lh:computed:FirstMeaningfulPaint",
45474546
"duration": 100,
45484547
"entryType": "measure"
45494548
},
@@ -5632,15 +5631,15 @@
56325631
},
56335632
{
56345633
"values": {
5635-
"timeInMs": 3969.136
5634+
"timeInMs": 4927.278
56365635
},
5637-
"path": "audits[first-meaningful-paint].displayValue"
5636+
"path": "audits[largest-contentful-paint].displayValue"
56385637
},
56395638
{
56405639
"values": {
5641-
"timeInMs": 4927.278
5640+
"timeInMs": 3969.136
56425641
},
5643-
"path": "audits[largest-contentful-paint].displayValue"
5642+
"path": "audits[first-meaningful-paint].displayValue"
56445643
},
56455644
{
56465645
"values": {
@@ -5673,19 +5672,19 @@
56735672
"path": "audits[bootup-time].displayValue"
56745673
}
56755674
],
5675+
"lighthouse-core/audits/metrics/largest-contentful-paint.js | title": [
5676+
"audits[largest-contentful-paint].title"
5677+
],
5678+
"lighthouse-core/audits/metrics/largest-contentful-paint.js | description": [
5679+
"audits[largest-contentful-paint].description"
5680+
],
56765681
"lighthouse-core/lib/i18n/i18n.js | firstMeaningfulPaintMetric": [
56775682
"audits[first-meaningful-paint].title",
56785683
"audits[timing-budget].details.items[2].label"
56795684
],
56805685
"lighthouse-core/audits/metrics/first-meaningful-paint.js | description": [
56815686
"audits[first-meaningful-paint].description"
56825687
],
5683-
"lighthouse-core/audits/metrics/largest-contentful-paint.js | title": [
5684-
"audits[largest-contentful-paint].title"
5685-
],
5686-
"lighthouse-core/audits/metrics/largest-contentful-paint.js | description": [
5687-
"audits[largest-contentful-paint].description"
5688-
],
56895688
"lighthouse-core/audits/load-fast-enough-for-pwa.js | title": [
56905689
"audits[load-fast-enough-for-pwa].title"
56915690
],
@@ -6970,4 +6969,4 @@
69706969
}
69716970
}
69726971
]
6973-
}
6972+
}

0 commit comments

Comments
 (0)