lighthouse 12.8.2-dev.20251004 → 12.8.2-dev.20251006

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/cli/test/smokehouse/config/exclusions.js +0 -2
  2. package/core/audits/audit.js +0 -1
  3. package/core/audits/insights/cls-culprits-insight.js +1 -1
  4. package/core/audits/insights/dom-size-insight.js +6 -6
  5. package/core/audits/redirects.js +1 -0
  6. package/core/audits/server-response-time.d.ts +0 -5
  7. package/core/audits/server-response-time.js +12 -26
  8. package/core/computed/metrics/lcp-breakdown.js +1 -0
  9. package/core/config/default-config.js +20 -63
  10. package/core/config/experimental-config.js +1 -26
  11. package/core/config/filters.js +6 -9
  12. package/core/config/lr-desktop-config.js +0 -1
  13. package/core/config/lr-mobile-config.js +0 -1
  14. package/core/gather/gatherers/trace-elements.js +1 -0
  15. package/core/lib/proto-preprocessor.js +5 -22
  16. package/dist/report/bundle.esm.js +10 -49
  17. package/dist/report/flow.js +12 -51
  18. package/dist/report/standalone.js +11 -50
  19. package/flow-report/src/i18n/i18n.d.ts +4 -6
  20. package/package.json +3 -3
  21. package/report/assets/styles.css +0 -39
  22. package/report/renderer/api.js +0 -1
  23. package/report/renderer/category-renderer.js +6 -0
  24. package/report/renderer/components.js +1 -1
  25. package/report/renderer/dom.d.ts +0 -13
  26. package/report/renderer/dom.js +0 -38
  27. package/report/renderer/performance-category-renderer.d.ts +0 -26
  28. package/report/renderer/performance-category-renderer.js +10 -142
  29. package/report/renderer/report-ui-features.d.ts +0 -1
  30. package/report/renderer/report-ui-features.js +3 -13
  31. package/report/renderer/report-utils.d.ts +2 -3
  32. package/report/renderer/report-utils.js +4 -6
  33. package/report/types/report-renderer.d.ts +0 -6
  34. package/shared/localization/locales/ar-XB.json +0 -330
  35. package/shared/localization/locales/ar.json +0 -330
  36. package/shared/localization/locales/bg.json +0 -330
  37. package/shared/localization/locales/ca.json +0 -330
  38. package/shared/localization/locales/cs.json +0 -330
  39. package/shared/localization/locales/da.json +0 -330
  40. package/shared/localization/locales/de.json +0 -330
  41. package/shared/localization/locales/el.json +0 -330
  42. package/shared/localization/locales/en-GB.json +0 -330
  43. package/shared/localization/locales/en-US.json +26 -275
  44. package/shared/localization/locales/en-XA.json +0 -330
  45. package/shared/localization/locales/en-XL.json +26 -275
  46. package/shared/localization/locales/es-419.json +0 -330
  47. package/shared/localization/locales/es.json +0 -330
  48. package/shared/localization/locales/fi.json +0 -330
  49. package/shared/localization/locales/fil.json +0 -330
  50. package/shared/localization/locales/fr.json +0 -330
  51. package/shared/localization/locales/he.json +0 -330
  52. package/shared/localization/locales/hi.json +0 -330
  53. package/shared/localization/locales/hr.json +0 -330
  54. package/shared/localization/locales/hu.json +0 -330
  55. package/shared/localization/locales/id.json +0 -330
  56. package/shared/localization/locales/it.json +0 -330
  57. package/shared/localization/locales/ja.json +0 -330
  58. package/shared/localization/locales/ko.json +0 -330
  59. package/shared/localization/locales/lt.json +0 -330
  60. package/shared/localization/locales/lv.json +0 -330
  61. package/shared/localization/locales/nl.json +0 -330
  62. package/shared/localization/locales/no.json +0 -330
  63. package/shared/localization/locales/pl.json +0 -330
  64. package/shared/localization/locales/pt-PT.json +0 -330
  65. package/shared/localization/locales/pt.json +0 -330
  66. package/shared/localization/locales/ro.json +0 -330
  67. package/shared/localization/locales/ru.json +0 -330
  68. package/shared/localization/locales/sk.json +0 -330
  69. package/shared/localization/locales/sl.json +0 -330
  70. package/shared/localization/locales/sr-Latn.json +0 -330
  71. package/shared/localization/locales/sr.json +0 -330
  72. package/shared/localization/locales/sv.json +0 -330
  73. package/shared/localization/locales/ta.json +0 -330
  74. package/shared/localization/locales/te.json +0 -330
  75. package/shared/localization/locales/th.json +0 -330
  76. package/shared/localization/locales/tr.json +0 -330
  77. package/shared/localization/locales/uk.json +0 -330
  78. package/shared/localization/locales/vi.json +0 -330
  79. package/shared/localization/locales/zh-HK.json +0 -330
  80. package/shared/localization/locales/zh-TW.json +0 -330
  81. package/shared/localization/locales/zh.json +0 -330
  82. package/types/artifacts.d.ts +1 -0
  83. package/types/audit.d.ts +1 -1
  84. package/types/lhr/settings.d.ts +1 -1
  85. package/core/audits/byte-efficiency/duplicated-javascript.d.ts +0 -45
  86. package/core/audits/byte-efficiency/duplicated-javascript.js +0 -223
  87. package/core/audits/byte-efficiency/efficient-animated-content.d.ts +0 -22
  88. package/core/audits/byte-efficiency/efficient-animated-content.js +0 -93
  89. package/core/audits/byte-efficiency/legacy-javascript.d.ts +0 -28
  90. package/core/audits/byte-efficiency/legacy-javascript.js +0 -144
  91. package/core/audits/byte-efficiency/modern-image-formats.d.ts +0 -38
  92. package/core/audits/byte-efficiency/modern-image-formats.js +0 -187
  93. package/core/audits/byte-efficiency/render-blocking-resources.d.ts +0 -53
  94. package/core/audits/byte-efficiency/render-blocking-resources.js +0 -312
  95. package/core/audits/byte-efficiency/uses-long-cache-ttl.d.ts +0 -59
  96. package/core/audits/byte-efficiency/uses-long-cache-ttl.js +0 -293
  97. package/core/audits/byte-efficiency/uses-optimized-images.d.ts +0 -33
  98. package/core/audits/byte-efficiency/uses-optimized-images.js +0 -146
  99. package/core/audits/byte-efficiency/uses-responsive-images-snapshot.d.ts +0 -16
  100. package/core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -106
  101. package/core/audits/byte-efficiency/uses-responsive-images.d.ts +0 -44
  102. package/core/audits/byte-efficiency/uses-responsive-images.js +0 -202
  103. package/core/audits/byte-efficiency/uses-text-compression.d.ts +0 -14
  104. package/core/audits/byte-efficiency/uses-text-compression.js +0 -108
  105. package/core/audits/critical-request-chains.d.ts +0 -44
  106. package/core/audits/critical-request-chains.js +0 -221
  107. package/core/audits/dobetterweb/dom-size.d.ts +0 -32
  108. package/core/audits/dobetterweb/dom-size.js +0 -182
  109. package/core/audits/dobetterweb/uses-http2.d.ts +0 -72
  110. package/core/audits/dobetterweb/uses-http2.js +0 -276
  111. package/core/audits/font-display.d.ts +0 -32
  112. package/core/audits/font-display.js +0 -195
  113. package/core/audits/largest-contentful-paint-element.d.ts +0 -34
  114. package/core/audits/largest-contentful-paint-element.js +0 -181
  115. package/core/audits/lcp-lazy-loaded.d.ts +0 -22
  116. package/core/audits/lcp-lazy-loaded.js +0 -115
  117. package/core/audits/prioritize-lcp-image.d.ts +0 -74
  118. package/core/audits/prioritize-lcp-image.js +0 -297
  119. package/core/audits/third-party-summary.d.ts +0 -78
  120. package/core/audits/third-party-summary.js +0 -236
  121. package/core/audits/uses-rel-preconnect.d.ts +0 -37
  122. package/core/audits/uses-rel-preconnect.js +0 -286
  123. package/core/audits/viewport.d.ts +0 -17
  124. package/core/audits/viewport.js +0 -87
  125. package/core/audits/work-during-interaction.d.ts +0 -81
  126. package/core/audits/work-during-interaction.js +0 -287
@@ -1,287 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2022 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import {Audit} from './audit.js';
8
- import {Responsiveness} from '../computed/metrics/responsiveness.js';
9
- import {ProcessedTrace} from '../computed/processed-trace.js';
10
- import * as i18n from '../lib/i18n/i18n.js';
11
- import {NetworkRecords} from '../computed/network-records.js';
12
- import {MainThreadTasks} from '../lib/tracehouse/main-thread-tasks.js';
13
- import {taskGroups} from '../lib/tracehouse/task-groups.js';
14
- import {TraceProcessor} from '../lib/tracehouse/trace-processor.js';
15
- import {getExecutionTimingsByURL} from '../lib/tracehouse/task-summary.js';
16
- import InteractionToNextPaint from './metrics/interaction-to-next-paint.js';
17
-
18
- /** @typedef {import('../computed/metrics/responsiveness.js').EventTimingEvent} EventTimingEvent */
19
- /** @typedef {import('../lib/tracehouse/main-thread-tasks.js').TaskNode} TaskNode */
20
-
21
- const TASK_THRESHOLD = 1;
22
-
23
- const UIStrings = {
24
- /** Title of a diagnostic audit that provides detail on the main thread work the browser did during a key user interaction. This descriptive title is shown to users when the amount is acceptable and no user action is required. */
25
- title: 'Minimizes work during key interaction',
26
- /** Title of a diagnostic audit that provides detail on the main thread work the browser did during a key user interaction. This imperative title is shown to users when there is a significant amount of execution time that could be reduced. */
27
- failureTitle: 'Minimize work during key interaction',
28
- /** Description of the work-during-interaction metric. This description is displayed within a tooltip when the user hovers on the metric name to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
29
- description: 'This is the thread-blocking work occurring during the Interaction to Next Paint measurement. [Learn more about the Interaction to Next Paint metric](https://web.dev/articles/inp).',
30
- /** Label for a column in a data table; entries will be information on the time that the browser is delayed before responding to user input. Ideally fits within a ~40 character limit. */
31
- inputDelay: 'Input delay',
32
- /** Label for a column in a data table; entries will be information on the time taken by code processing user input that delays a response to the user. Ideally fits within a ~40 character limit. */
33
- processingDuration: 'Processing duration',
34
- /** Label for a column in a data table; entries will be information on the time that the browser is delayed before presenting a response to user input on screen. Ideally fits within a ~40 character limit. */
35
- presentationDelay: 'Presentation delay',
36
- /**
37
- * @description Summary text that identifies the time the browser took to process a user interaction.
38
- * @example {mousedown} interactionType
39
- */
40
- displayValue: `{timeInMs, number, milliseconds}\xa0ms spent on event '{interactionType}'`,
41
- /** Label for a column in a data table; entries will the UI element that was the target of a user interaction (for example, a button that was clicked on). Ideally fits within a ~40 character limit. */
42
- eventTarget: 'Event target',
43
- };
44
-
45
- const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
46
-
47
- /**
48
- * @fileoverview This metric gives a high-percentile measure of responsiveness to input.
49
- */
50
- class WorkDuringInteraction extends Audit {
51
- /**
52
- * @return {LH.Audit.Meta}
53
- */
54
- static get meta() {
55
- return {
56
- id: 'work-during-interaction',
57
- title: str_(UIStrings.title),
58
- failureTitle: str_(UIStrings.failureTitle),
59
- description: str_(UIStrings.description),
60
- scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
61
- supportedModes: ['timespan'],
62
- guidanceLevel: 1,
63
- requiredArtifacts: ['Trace', 'DevtoolsLog', 'TraceElements'],
64
- };
65
- }
66
-
67
- /**
68
- * @param {TaskNode} task
69
- * @param {TaskNode|undefined} parent
70
- * @param {number} startTs
71
- * @param {number} endTs
72
- * @return {number}
73
- */
74
- static recursivelyClipTasks(task, parent, startTs, endTs) {
75
- const taskEventStart = task.event.ts;
76
- const taskEventEnd = task.endEvent?.ts ?? task.event.ts + Number(task.event.dur || 0);
77
-
78
- task.startTime = Math.max(startTs, Math.min(endTs, taskEventStart)) / 1000;
79
- task.endTime = Math.max(startTs, Math.min(endTs, taskEventEnd)) / 1000;
80
- task.duration = task.endTime - task.startTime;
81
-
82
- const childTime = task.children
83
- .map(child => WorkDuringInteraction.recursivelyClipTasks(child, task, startTs, endTs))
84
- .reduce((sum, child) => sum + child, 0);
85
- task.selfTime = task.duration - childTime;
86
- return task.duration;
87
- }
88
-
89
- /**
90
- * Clip the tasks by the start and end points. Take the easy route and drop
91
- * to duration 0 if out of bounds, since only durations are needed in the
92
- * end (for now).
93
- * Assumes owned tasks, so modifies in place. Can be called multiple times on
94
- * the same `tasks` because always computed from original event timing.
95
- * @param {Array<TaskNode>} tasks
96
- * @param {number} startTs
97
- * @param {number} endTs
98
- */
99
- static clipTasksByTs(tasks, startTs, endTs) {
100
- for (const task of tasks) {
101
- if (task.parent) continue;
102
- WorkDuringInteraction.recursivelyClipTasks(task, undefined, startTs, endTs);
103
- }
104
- }
105
-
106
- /**
107
- * @param {EventTimingEvent} interactionEvent
108
- */
109
- static getPhaseTimes(interactionEvent) {
110
- const interactionData = interactionEvent.args.data;
111
- const startTs = interactionEvent.ts;
112
- const navStart = startTs - interactionData.timeStamp * 1000;
113
- const processingStartTs = navStart + interactionData.processingStart * 1000;
114
- const processingEndTs = navStart + interactionData.processingEnd * 1000;
115
- const endTs = startTs + interactionData.duration * 1000;
116
- return {
117
- inputDelay: {startTs, endTs: processingStartTs},
118
- processingDuration: {startTs: processingStartTs, endTs: processingEndTs},
119
- presentationDelay: {startTs: processingEndTs, endTs},
120
- };
121
- }
122
-
123
- /**
124
- * @param {EventTimingEvent} interactionEvent
125
- * @param {LH.Trace} trace
126
- * @param {LH.Artifacts.ProcessedTrace} processedTrace
127
- * @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
128
- * @return {{table: LH.Audit.Details.Table, phases: Record<string, {startTs: number, endTs: number}>}}
129
- */
130
- static getThreadBreakdownTable(interactionEvent, trace, processedTrace, networkRecords) {
131
- // Limit to interactionEvent's thread.
132
- // TODO(bckenny): limit to interactionEvent's navigation.
133
- const threadEvents = TraceProcessor.filteredTraceSort(trace.traceEvents, evt => {
134
- return evt.pid === interactionEvent.pid && evt.tid === interactionEvent.tid;
135
- });
136
- const traceEndTs = threadEvents.reduce((endTs, evt) => {
137
- return Math.max(evt.ts + (evt.dur || 0), endTs);
138
- }, 0);
139
- // frames is only used for URL attribution, so can include all frames, even if OOPIF.
140
- const {frames} = processedTrace;
141
- const threadTasks = MainThreadTasks.getMainThreadTasks(threadEvents, frames, traceEndTs);
142
-
143
- const phases = WorkDuringInteraction.getPhaseTimes(interactionEvent);
144
-
145
- /** @type {LH.Audit.Details.TableItem[]} */
146
- const items = [];
147
- for (const [phaseName, phaseTimes] of Object.entries(phases)) {
148
- // Clip tasks to start and end time.
149
- WorkDuringInteraction.clipTasksByTs(threadTasks, phaseTimes.startTs, phaseTimes.endTs);
150
- const executionTimings = getExecutionTimingsByURL(threadTasks, networkRecords);
151
-
152
- const results = [];
153
- for (const [url, timingByGroupId] of executionTimings) {
154
- const totalExecutionTimeForURL = Object.values(timingByGroupId)
155
- .reduce((total, timespanMs) => total + timespanMs);
156
-
157
- const scriptingTotal = timingByGroupId[taskGroups.scriptEvaluation.id] || 0;
158
- const layoutTotal = timingByGroupId[taskGroups.styleLayout.id] || 0;
159
- const renderTotal = timingByGroupId[taskGroups.paintCompositeRender.id] || 0;
160
-
161
- results.push({
162
- url: url,
163
- total: totalExecutionTimeForURL,
164
- scripting: scriptingTotal,
165
- layout: layoutTotal,
166
- render: renderTotal,
167
- });
168
- }
169
-
170
- const filteredResults = results
171
- .filter(result => result.total > TASK_THRESHOLD)
172
- .sort((a, b) => b.total - a.total);
173
-
174
- items.push({
175
- phase: str_(UIStrings[/** @type {keyof UIStrings} */ (phaseName)]),
176
- total: (phaseTimes.endTs - phaseTimes.startTs) / 1000,
177
- subItems: {
178
- type: 'subitems',
179
- items: filteredResults,
180
- },
181
- });
182
- }
183
-
184
- /** @type {LH.Audit.Details.Table['headings']} */
185
- const headings = [
186
- /* eslint-disable max-len */
187
- {key: 'phase', valueType: 'text', subItemsHeading: {key: 'url', valueType: 'url'}, label: 'Phase'},
188
- {key: 'total', valueType: 'ms', subItemsHeading: {key: 'total', granularity: 1, valueType: 'ms'}, granularity: 1, label: 'Total time'},
189
- {key: null, valueType: 'ms', subItemsHeading: {key: 'scripting', granularity: 1, valueType: 'ms'}, label: 'Script evaluation'},
190
- {key: null, valueType: 'ms', subItemsHeading: {key: 'layout', granularity: 1, valueType: 'ms'}, label: taskGroups.styleLayout.label},
191
- {key: null, valueType: 'ms', subItemsHeading: {key: 'render', granularity: 1, valueType: 'ms'}, label: taskGroups.paintCompositeRender.label},
192
- /* eslint-enable max-len */
193
- ];
194
-
195
- return {
196
- table: Audit.makeTableDetails(headings, items, {sortedBy: ['total']}),
197
- phases,
198
- };
199
- }
200
-
201
- /**
202
- * @param {LH.Artifacts['TraceElements']} traceElements
203
- * @return {LH.Audit.Details.Table | undefined}
204
- */
205
- static getTraceElementTable(traceElements) {
206
- const responsivenessElement = traceElements.find(el => el.traceEventType === 'responsiveness');
207
- if (!responsivenessElement) return;
208
-
209
- /** @type {LH.Audit.Details.Table['headings']} */
210
- const headings = [
211
- {key: 'node', valueType: 'node', label: str_(UIStrings.eventTarget)},
212
- ];
213
- const elementItems = [{node: Audit.makeNodeItem(responsivenessElement.node)}];
214
-
215
- return Audit.makeTableDetails(headings, elementItems);
216
- }
217
-
218
- /**
219
- * @param {LH.Artifacts} artifacts
220
- * @param {LH.Audit.Context} context
221
- * @return {Promise<LH.Audit.Product>}
222
- */
223
- static async audit(artifacts, context) {
224
- const {settings} = context;
225
- // TODO: responsiveness isn't yet supported by lantern.
226
- if (settings.throttlingMethod === 'simulate') {
227
- return {
228
- score: null,
229
- notApplicable: true,
230
- metricSavings: {INP: 0},
231
- };
232
- }
233
-
234
- const trace = artifacts.Trace;
235
- const metricData = {trace, settings};
236
- const interactionEvent = await Responsiveness.request(metricData, context);
237
- // If no interaction, diagnostic audit is n/a.
238
- if (interactionEvent === null) {
239
- return {
240
- score: null,
241
- notApplicable: true,
242
- metricSavings: {INP: 0},
243
- };
244
- }
245
-
246
- const auditDetailsItems = [];
247
-
248
- const traceElementItem = WorkDuringInteraction.getTraceElementTable(artifacts.TraceElements);
249
- if (traceElementItem) auditDetailsItems.push(traceElementItem);
250
-
251
- const devtoolsLog = artifacts.DevtoolsLog;
252
- // Network records will usually be empty for timespans.
253
- const networkRecords = await NetworkRecords.request(devtoolsLog, context);
254
- const processedTrace = await ProcessedTrace.request(trace, context);
255
- const {table: breakdownTable, phases} = WorkDuringInteraction.getThreadBreakdownTable(
256
- interactionEvent, trace, processedTrace, networkRecords);
257
- auditDetailsItems.push(breakdownTable);
258
-
259
- const interactionType = interactionEvent.args.data.type;
260
- auditDetailsItems.push({
261
- type: /** @type {const} */ ('debugdata'),
262
- interactionType,
263
- phases,
264
- });
265
-
266
- const duration = interactionEvent.args.data.duration;
267
- const displayValue = str_(UIStrings.displayValue, {timeInMs: duration, interactionType});
268
-
269
- const passed = duration < InteractionToNextPaint.defaultOptions.p10;
270
-
271
- return {
272
- score: passed ? 1 : 0,
273
- scoreDisplayMode: passed ? Audit.SCORING_MODES.INFORMATIVE : undefined,
274
- displayValue,
275
- details: {
276
- type: 'list',
277
- items: auditDetailsItems,
278
- },
279
- metricSavings: {
280
- INP: duration,
281
- },
282
- };
283
- }
284
- }
285
-
286
- export default WorkDuringInteraction;
287
- export {UIStrings};