From 8df117f1182a213407c0fa57d057d11c3a2330ca Mon Sep 17 00:00:00 2001 From: Derek Lewis Date: Mon, 31 Aug 2026 22:28:06 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=F0=9F=9A=80=EF=BC=9Astop=20shippin?= =?UTF-8?q?g=20the=20CSS=20nothing=20wears?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The stylesheet was 158 KB, a third of the whole site, blocking the render of every page. Browser coverage put 34 KB of it to work and left the rest untouched; 125 KB of the 158 came from Bootstrap. Three things went. `pagination` styles a component the markup never names -- no `.pagination`, `.page-item` or `.page-link` anywhere. `grid` was the same: no `.row` and no `.col-*`, the `invite-row` and `join-row` in the markup being ours. The utility API was the large one, generating a class for every value of every utility, 69 KB of it, while the markup wears eighteen: the displays, one flex direction and shrink, a width, a height, five margins, two paddings, a text alignment and two colors. It is handed those thirteen groups now. `map.get` needs `sass:map`, and a `@use` has to precede every import, so it sits above the file. 94 KB, and the same site: nine pages at two widths render pixel for pixel as they did, and the drawer still opens on one tap. Signed-off-by: Derek Lewis Assisted-by: Claude-Code:claude-opus-5 --- _assets/styles/main.scss | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/_assets/styles/main.scss b/_assets/styles/main.scss index 77ccdef65..a1f478946 100644 --- a/_assets/styles/main.scss +++ b/_assets/styles/main.scss @@ -1,3 +1,6 @@ +// `map.get` below needs the module; `@use` has to precede every import. +@use 'sass:map'; + // Functions first. @import '../../node_modules/bootstrap/scss/functions'; @@ -15,7 +18,6 @@ @import '../../node_modules/bootstrap/scss/buttons'; @import '../../node_modules/bootstrap/scss/nav'; @import '../../node_modules/bootstrap/scss/navbar'; -@import '../../node_modules/bootstrap/scss/pagination'; @import 'about'; @import 'shell'; @import 'docs'; @@ -30,8 +32,27 @@ @import '../../node_modules/bootstrap/scss/utilities'; @import '../../node_modules/bootstrap/scss/reboot'; @import '../../node_modules/bootstrap/scss/containers'; -@import '../../node_modules/bootstrap/scss/grid'; @import '../../node_modules/bootstrap/scss/helpers'; + +// The API below generates a class for every value of every utility it is +// handed, which came to two thirds of the stylesheet. Handing it only the +// groups the markup uses costs a line here when a new one is wanted. +$utilities: ( + 'background-color': map.get($utilities, 'background-color'), + 'color': map.get($utilities, 'color'), + 'display': map.get($utilities, 'display'), + 'flex-direction': map.get($utilities, 'flex-direction'), + 'flex-shrink': map.get($utilities, 'flex-shrink'), + 'height': map.get($utilities, 'height'), + 'margin-bottom': map.get($utilities, 'margin-bottom'), + 'margin-end': map.get($utilities, 'margin-end'), + 'margin-top': map.get($utilities, 'margin-top'), + 'margin-y': map.get($utilities, 'margin-y'), + 'padding-y': map.get($utilities, 'padding-y'), + 'text-align': map.get($utilities, 'text-align'), + 'width': map.get($utilities, 'width'), +); + @import '../../node_modules/bootstrap/scss/utilities/api'; // Miscellaneous custom styles.