';
if (p1.renderBlocking && p2.renderBlocking) {
- html += section('Render blocking');
+ html += section('Render blocking', 'blocking');
html += '
Render blocking
' +
'
' + p1.renderBlocking.blocking + '
' +
'
' + p2.renderBlocking.blocking + '
';
@@ -176,11 +177,18 @@ function pageXrayTemplate(d) {
'
' + formatTime(p2.visualMetrics[key]) + '
';
}
});
- if (vmHtml) html += section('Visual metrics') + vmHtml;
+ if (vmHtml) html += section('Visual metrics', 'visual') + vmHtml;
}
if (p1.googleWebVitals && p2.googleWebVitals) {
- html += section('Core Web Vitals');
+ // CLS is a unitless float that browsers report at full precision
+ // (e.g. 0.05641193152186011). Round to three decimals — that's
+ // the granularity that matters for comparison and matches the
+ // convention used in the sitespeed.io HTML report.
+ function fmtCLS(v) {
+ return typeof v === 'number' ? v.toFixed(3) : (v == null ? '' : v);
+ }
+ html += section('Core Web Vitals', 'cwv');
html += '
';
}
if (p1.cpu && p2.cpu && p1.cpu.longTasks && p2.cpu.longTasks) {
@@ -212,7 +220,7 @@ function pageXrayTemplate(d) {
'
' + p1.cpu.longTasks.tasks + '
' +
'
' + p2.cpu.longTasks.tasks + '
';
}
- if (cpuHtml) html += section('CPU') + cpuHtml;
+ if (cpuHtml) html += section('CPU', 'cpu') + cpuHtml;
}
if (d.cpuCategories1 && d.cpuCategories2) {
@@ -221,7 +229,7 @@ function pageXrayTemplate(d) {
// CPU has no long-task data but we still want the disclosure rows
// visually under a heading).
if (!(p1.cpu && p2.cpu && p1.cpu.longTasks && p2.cpu.longTasks)) {
- html += section('CPU');
+ html += section('CPU', 'cpu');
}
html += '
CPU time spent by category ' +
'
';
}
- if (capturesHtml) html += section('Captures') + capturesHtml;
+ if (capturesHtml) html += section('Captures', 'captures') + capturesHtml;
html += '';
return html;
diff --git a/src/css/page-xray.css b/src/css/page-xray.css
index f20a32a..cc7fab0 100644
--- a/src/css/page-xray.css
+++ b/src/css/page-xray.css
@@ -16,11 +16,12 @@
/*
* Section divider rows — full-width header cells inserted between
- * groups of related metrics ("Content", "Visual metrics", "Core Web
- * Vitals", "CPU", "Captures"). Reads as a quiet, scannable label
- * rather than competing with the data rows: small caps, secondary
- * text colour, extra top padding to separate it from the previous
- * group, and no hover treatment.
+ * groups of related metrics ("Content", "Render blocking", "Visual
+ * metrics", "Core Web Vitals", "CPU", "Captures"). Each kind gets
+ * its own quiet pastel/text pair so the eye can tell sections apart
+ * at a glance instead of seeing identical bars stacked down the
+ * table. Hover is suppressed so they stay visually distinct from
+ * data rows.
*/
.pageXrayTable .pageXraySection th {
text-align: left;
@@ -28,15 +29,30 @@
font-weight: var(--font-weight-semibold);
letter-spacing: 0.08em;
text-transform: uppercase;
- color: var(--color-text-muted);
- background: var(--color-surface);
padding: 14px 12px 6px;
border-bottom: 1px solid var(--color-border);
}
.pageXrayTable .pageXraySection:hover th {
- background: var(--color-surface);
+ /* Keep the section's own background on hover — re-set in each
+ modifier below; this rule just disables the default row-hover
+ tint that the .pageXrayTable tr:hover rule would otherwise paint. */
}
+.pageXrayTable .pageXraySection--content th { background: var(--color-info-bg); color: var(--color-info); }
+.pageXrayTable .pageXraySection--blocking th { background: var(--color-warning-bg); color: var(--color-warning); }
+.pageXrayTable .pageXraySection--visual th { background: #f3e8ff; color: #6b21a8; }
+.pageXrayTable .pageXraySection--cwv th { background: var(--color-ok-bg); color: var(--color-ok); }
+.pageXrayTable .pageXraySection--cpu th { background: #ffedd5; color: #9a3412; }
+.pageXrayTable .pageXraySection--captures th { background: var(--color-surface); color: var(--color-text-muted); }
+
+/* Repeat for hover so the bg doesn't snap to the row-hover tint. */
+.pageXrayTable .pageXraySection--content:hover th { background: var(--color-info-bg); }
+.pageXrayTable .pageXraySection--blocking:hover th { background: var(--color-warning-bg); }
+.pageXrayTable .pageXraySection--visual:hover th { background: #f3e8ff; }
+.pageXrayTable .pageXraySection--cwv:hover th { background: var(--color-ok-bg); }
+.pageXrayTable .pageXraySection--cpu:hover th { background: #ffedd5; }
+.pageXrayTable .pageXraySection--captures:hover th { background: var(--color-surface); }
+
.pageXrayTable {
table-layout: fixed;