Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Record how many bytes of CSS a page loads (#82541)

Romeo Van Snick2602fec3cdcc
diff --git a/.github/scripts/upload-bundle-load-stats.ts b/.github/scripts/upload-bundle-load-stats.ts
index 6f86129584f..3178e002bed 100644
--- a/.github/scripts/upload-bundle-load-stats.ts
+++ b/.github/scripts/upload-bundle-load-stats.ts
@@ -29,6 +29,7 @@ interface Condition {
locale: string;
scripts: number;
scriptKb: number;
+ cssKb: number;
totalKb: number;
runs: number;
}
@@ -78,6 +79,7 @@ function buildRows(
Locale: condition.locale,
Scripts: condition.scripts,
"Script kb": condition.scriptKb,
+ "Css kb": condition.cssKb,
"Total kb": condition.totalKb,
Runs: condition.runs,
}));
diff --git a/frontend/test/bench/matrix.ts b/frontend/test/bench/matrix.ts
index 5de473412de..a0ac89029a1 100644
--- a/frontend/test/bench/matrix.ts
+++ b/frontend/test/bench/matrix.ts
@@ -37,6 +37,7 @@ interface Series {
locale: string;
scripts: number;
scriptKb: number;
+ cssKb: number;
totalKb: number;
median: Timings;
secondLoad: Timings | null;
@@ -200,6 +201,7 @@ function spreadPercent(values: number[]) {
locale: cold.locale,
scripts: cold.scripts,
scriptKb: cold.scriptKb,
+ cssKb: cold.cssKb,
totalKb: cold.totalKb,
runs: cold.runs,
});
diff --git a/frontend/test/bench/measure.ts b/frontend/test/bench/measure.ts
index 6227d485241..a0a1c201159 100644
--- a/frontend/test/bench/measure.ts
+++ b/frontend/test/bench/measure.ts
@@ -55,6 +55,7 @@ interface Run {
lastScriptEnd: number;
scriptCount: number;
scriptBytes: number;
+ styleBytes: number;
totalBytes: number;
}
@@ -139,6 +140,10 @@ const READ_METRICS = `JSON.stringify((() => {
lastScriptEnd: Math.max(0, ...scripts.map((entry) => entry.responseEnd)),
scriptCount: scripts.length,
scriptBytes: scripts.reduce((total, entry) => total + entry.encodedBodySize, 0),
+ styleBytes: performance
+ .getEntriesByType("resource")
+ .filter((entry) => entry.name.endsWith(".css"))
+ .reduce((total, entry) => total + entry.encodedBodySize, 0),
// Every byte the page fetched so far, compressed as it arrived: the document
// itself, then each script, stylesheet, font, image and API response.
totalBytes: (nav ? nav.encodedBodySize : 0) + performance
@@ -342,6 +347,7 @@ function timings(run: Run) {
locale: results[0].language,
scripts: results[0].scriptCount,
scriptKb: Number((results[0].scriptBytes / 1024).toFixed(1)),
+ cssKb: Number((results[0].styleBytes / 1024).toFixed(1)),
// Read at the same moment as `scriptKb`, so the difference between the
// two is everything the page loaded that is not script.
totalKb: Number((results[0].totalBytes / 1024).toFixed(1)),