Skip to content

Commit cfa11f3

Browse files
Connor ClarkDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Add estimated byte savings to Duplicated JavaScript insight
Also fix #shouldShowTreemap Bug: 394373632 Change-Id: Ia34504bfa8a99c6c5d5d12212ddcae463490b0dd Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6404285 Reviewed-by: Paul Irish <[email protected]> Auto-Submit: Connor Clark <[email protected]> Commit-Queue: Connor Clark <[email protected]>
1 parent 3a037ad commit cfa11f3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

front_end/panels/timeline/components/insights/DuplicatedJavaScript.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class DuplicatedJavaScript extends BaseInsightComponent<DuplicateJavaScri
3131
return false;
3232
}
3333

34-
return this.model.scripts.length > 0;
34+
return this.model.scripts.some(script => !!script.url);
3535
}
3636

3737
#openTreemap(): void {
@@ -51,6 +51,19 @@ export class DuplicatedJavaScript extends BaseInsightComponent<DuplicateJavaScri
5151
return this.model?.metricSavings?.FCP ?? null;
5252
}
5353

54+
override getEstimatedSavingsBytes(): number|null {
55+
if (!this.model) {
56+
return null;
57+
}
58+
59+
let totalDuplicatedBytes = 0;
60+
for (const data of this.model.duplicationGroupedByNodeModules.values()) {
61+
totalDuplicatedBytes += data.estimatedDuplicateBytes;
62+
}
63+
64+
return totalDuplicatedBytes;
65+
}
66+
5467
override createOverlays(): Overlays.Overlays.TimelineOverlay[] {
5568
if (!this.model) {
5669
return [];

0 commit comments

Comments
 (0)