forked from GoogleChrome/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperf-fonts.js
94 lines (90 loc) · 3.22 KB
/
perf-fonts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* @license Copyright 2017 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
/** @type {LH.Config.Json} */
const config = {
extends: 'lighthouse:default',
settings: {
throttlingMethod: 'devtools',
// preload-fonts isn't a performance audit, but can easily leverage the font
// webpages present here, hence the inclusion of 'best-practices'.
onlyCategories: ['performance', 'best-practices'],
// A mixture of under, over, and meeting budget to exercise all paths.
budgets: [{
path: '/',
resourceCounts: [
{resourceType: 'total', budget: 8},
{resourceType: 'stylesheet', budget: 1}, // meets budget
{resourceType: 'image', budget: 1},
{resourceType: 'media', budget: 0},
{resourceType: 'font', budget: 2}, // meets budget
{resourceType: 'script', budget: 1},
{resourceType: 'document', budget: 0},
{resourceType: 'other', budget: 1},
{resourceType: 'third-party', budget: 0},
],
resourceSizes: [
{resourceType: 'total', budget: 100},
{resourceType: 'stylesheet', budget: 0},
{resourceType: 'image', budget: 30}, // meets budget
{resourceType: 'media', budget: 0},
{resourceType: 'font', budget: 75},
{resourceType: 'script', budget: 30},
{resourceType: 'document', budget: 1},
{resourceType: 'other', budget: 2}, // meets budget
{resourceType: 'third-party', budget: 0},
],
timings: [
{metric: 'first-contentful-paint', budget: 2000},
{metric: 'interactive', budget: 2000},
{metric: 'first-meaningful-paint', budget: 2000},
{metric: 'max-potential-fid', budget: 2000},
],
}],
},
};
/**
* @type {Smokehouse.ExpectedRunnerResult}
* Expected Lighthouse audit values for testing font perf.
*/
const expectations = {
networkRequests: {
length: 5,
},
lhr: {
requestedUrl: 'http://localhost:10200/perf/fonts.html',
finalUrl: 'http://localhost:10200/perf/fonts.html',
audits: {
'font-display': {
score: 0,
details: {
items: [
{
url: 'http://localhost:10200/perf/lobster-v20-latin-regular.woff2',
},
],
},
},
'preload-fonts': {
scoreDisplayMode: 'notApplicable',
// Disabled for now, see https://github.com/GoogleChrome/lighthouse/issues/11960
// score: 0,
// details: {
// items: [
// {
// url: 'http://localhost:10200/perf/lobster-two-v10-latin-700.woff2?delay=1000',
// },
// ],
// },
},
},
},
};
export default {
id: 'perf-fonts',
expectations,
config,
runSerially: true,
};