lighthouse 12.5.1-dev.20250423 → 12.5.1-dev.20250424
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.
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
|
|
17
17
|
import {Audit} from './audit.js';
|
|
18
18
|
import {JSBundles} from '../computed/js-bundles.js';
|
|
19
|
+
import {NetworkRecords} from '../computed/network-records.js';
|
|
19
20
|
import {UnusedJavascriptSummary} from '../computed/unused-javascript-summary.js';
|
|
20
21
|
import {ModuleDuplication} from '../computed/module-duplication.js';
|
|
21
|
-
import {isInline} from '../lib/script-helpers.js';
|
|
22
|
+
import {getRequestForScript, isInline} from '../lib/script-helpers.js';
|
|
22
23
|
|
|
23
24
|
class ScriptTreemapDataAudit extends Audit {
|
|
24
25
|
/**
|
|
@@ -54,6 +55,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
54
55
|
return {
|
|
55
56
|
name,
|
|
56
57
|
resourceBytes: 0,
|
|
58
|
+
encodedBytes: undefined,
|
|
57
59
|
};
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -167,6 +169,9 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
167
169
|
* @return {Promise<LH.Treemap.Node[]>}
|
|
168
170
|
*/
|
|
169
171
|
static async makeNodes(artifacts, context) {
|
|
172
|
+
const devtoolsLog = artifacts.DevtoolsLog;
|
|
173
|
+
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
174
|
+
|
|
170
175
|
/** @type {LH.Treemap.Node[]} */
|
|
171
176
|
const nodes = [];
|
|
172
177
|
/** @type {Map<string, LH.Treemap.Node>} */
|
|
@@ -234,6 +239,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
234
239
|
node = {
|
|
235
240
|
name,
|
|
236
241
|
resourceBytes: unusedJavascriptSummary?.totalBytes ?? script.length ?? 0,
|
|
242
|
+
encodedBytes: undefined,
|
|
237
243
|
unusedBytes: unusedJavascriptSummary?.wastedBytes,
|
|
238
244
|
};
|
|
239
245
|
}
|
|
@@ -246,6 +252,7 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
246
252
|
htmlNode = {
|
|
247
253
|
name,
|
|
248
254
|
resourceBytes: 0,
|
|
255
|
+
encodedBytes: undefined,
|
|
249
256
|
unusedBytes: undefined,
|
|
250
257
|
children: [],
|
|
251
258
|
};
|
|
@@ -261,6 +268,29 @@ class ScriptTreemapDataAudit extends Audit {
|
|
|
261
268
|
} else {
|
|
262
269
|
// Non-inline scripts each have their own top-level node.
|
|
263
270
|
nodes.push(node);
|
|
271
|
+
|
|
272
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
273
|
+
if (networkRecord) {
|
|
274
|
+
const bodyTransferSize =
|
|
275
|
+
networkRecord.transferSize - networkRecord.responseHeadersTransferSize;
|
|
276
|
+
node.encodedBytes = bodyTransferSize;
|
|
277
|
+
} else {
|
|
278
|
+
node.encodedBytes = node.resourceBytes;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// For the HTML nodes, set encodedBytes to be the size of all the inline
|
|
284
|
+
// scripts multiplied by the average compression ratio of the HTML document.
|
|
285
|
+
for (const [frameId, node] of htmlNodesByFrameId) {
|
|
286
|
+
const record =
|
|
287
|
+
networkRecords.find(r => r.resourceType === 'Document' && r.frameId === frameId);
|
|
288
|
+
if (record) {
|
|
289
|
+
const inlineScriptsPct = node.resourceBytes / record.resourceSize;
|
|
290
|
+
const bodyTransferSize = record.transferSize - record.responseHeadersTransferSize;
|
|
291
|
+
node.encodedBytes = Math.floor(bodyTransferSize * inlineScriptsPct);
|
|
292
|
+
} else {
|
|
293
|
+
node.encodedBytes = node.resourceBytes;
|
|
264
294
|
}
|
|
265
295
|
}
|
|
266
296
|
|
package/core/scoring.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ export class ReportScoring {
|
|
|
79
79
|
nodes: {
|
|
80
80
|
name: string | import("./index.js").IcuMessage;
|
|
81
81
|
resourceBytes: number;
|
|
82
|
+
encodedBytes?: number | undefined;
|
|
82
83
|
unusedBytes?: number | undefined;
|
|
83
84
|
duplicatedNormalizedModuleName?: string | import("./index.js").IcuMessage | undefined;
|
|
84
85
|
children?: /*elided*/ any[] | undefined;
|
package/package.json
CHANGED
|
@@ -3743,6 +3743,9 @@
|
|
|
3743
3743
|
"treemap/app/src/util.js | toggleTableButtonLabel": {
|
|
3744
3744
|
"message": "Toggle table"
|
|
3745
3745
|
},
|
|
3746
|
+
"treemap/app/src/util.js | transferBytesLabel": {
|
|
3747
|
+
"message": "Transfer bytes"
|
|
3748
|
+
},
|
|
3746
3749
|
"treemap/app/src/util.js | unusedBytesLabel": {
|
|
3747
3750
|
"message": "Unused bytes"
|
|
3748
3751
|
}
|
|
@@ -3743,6 +3743,9 @@
|
|
|
3743
3743
|
"treemap/app/src/util.js | toggleTableButtonLabel": {
|
|
3744
3744
|
"message": "T̂óĝǵl̂é t̂áb̂ĺê"
|
|
3745
3745
|
},
|
|
3746
|
+
"treemap/app/src/util.js | transferBytesLabel": {
|
|
3747
|
+
"message": "T̂ŕâńŝf́êŕ b̂ýt̂éŝ"
|
|
3748
|
+
},
|
|
3746
3749
|
"treemap/app/src/util.js | unusedBytesLabel": {
|
|
3747
3750
|
"message": "Ûńûśêd́ b̂ýt̂éŝ"
|
|
3748
3751
|
}
|
package/types/lhr/treemap.d.ts
CHANGED
|
@@ -49,6 +49,9 @@ declare module Treemap {
|
|
|
49
49
|
/** Could be a url, a path component from a source map, or an arbitrary string. */
|
|
50
50
|
name: string;
|
|
51
51
|
resourceBytes: number;
|
|
52
|
+
/** Transfer size of the script. Only set for non-inline top-level script nodes. */
|
|
53
|
+
encodedBytes?: number;
|
|
54
|
+
/** Unused bytes, in terms of resource size. */
|
|
52
55
|
unusedBytes?: number;
|
|
53
56
|
/** If present, this module is a duplicate. String is normalized source path. See ModuleDuplication.normalizeSource */
|
|
54
57
|
duplicatedNormalizedModuleName?: string;
|