Our stylesheet registers 53 custom properties, and 44 of them never leave their starting value on any of our 38 pages
Notifio has 38 public pages, and all of them load one stylesheet, 39,856 bytes of it. Yesterday's post about that file counted what its rules match. It mentioned in one sentence that 54 of the 611 rules were @property re
Notifio has 38 public pages, and all of them load one stylesheet, 39,856 bytes of it. Yesterday's post about that file counted what its rules match. It mentioned in one sentence that 54 of the 611 rules were @property registrations and then moved on, because a style rule either matches an element or it does not, and a registration is a different kind of thing. It does not match anything. It declares that a custom property exists, what type it has, and what value it holds before anyone sets it.
So the question for those rules is not "does it match" but "does anything ever hold a value other than the starting one". This post answers that for the live site.
What is in the file
The sheet served at the time of writing has 53 registrations (yesterday's post counted 54; I have not worked out why it is 53 today, and the repository moving from Tailwind 4.3.3 to 4.3.5 in the meantime is only a suspect). Together they are 3,230 bytes, 8.1 per cent of the file. All of them look like this:
@property --tw-backdrop-blur{syntax:"*";inherits:false}
@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}
Tailwind 4 writes them for the building blocks of its utilities (--tw-translate-x, --tw-ring-shadow, --tw-blur), which, as far as I can tell, gives each one a defined type and starting value. They are not ours. We never wrote one.
The measurement
For each of the 38 URLs in the sitemap, I loaded the page in Chromium at 1280 by 800, waited for the network to go idle, and looked at every element:
for (const el of document.querySelectorAll("*")) {
const cs = getComputedStyle(el);
for (const p of props) {
const v = cs.getPropertyValue(p.name).trim();
if (v !== (p.initial ?? "")) hit[p.name]++;
}
}
That reads 53 properties on every element of every page: 8,971 elements across the 38 pages. The home page animates, so I sampled it four times, 900 ms apart, and kept the highest count. A property counts as live if, on any element of any page, the computed value is not its registered starting value.
The result
Nine of the 53 are ever anything but their start value. Forty-four never are.
live, on all 38 pages (typography, from the base layer)
--tw-leading 934 elements
--tw-font-weight 1,413 elements
--tw-tracking 775 elements
--tw-duration 107 elements
--tw-ease 76 elements
live, on one page (the home page, from the demos)
--tw-translate-x 1 element
--tw-translate-y 1 element
--tw-shadow 2 elements
--tw-backdrop-blur 3 elements
The second group is the only place on the site where a transform or a shadow is built out of these pieces. I confirmed what I could: the one backdrop-blur-sm class on the whole site is in the home page's HTML and on no other page, and the -translate-x-1/2 class is also only on the home page. The rest are seen in the computed values and not traced further.
The 44 that never change fall into five families:
shadows and rings (13) shadow-color, shadow-alpha, inset-shadow x3, ring-color,
ring-shadow, inset-ring x2, ring-inset, ring-offset x3
filters (13) blur, brightness, contrast, grayscale, hue-rotate, invert,
opacity, saturate, sepia, drop-shadow x4
backdrop filters (8) brightness, contrast, grayscale, hue-rotate, invert,
opacity, saturate, sepia
transforms (6) translate-z, rotate x/y/z, skew x/y
reverse and border (4) space-y-reverse, divide-x/y-reverse, border-style
Why eight are there at all
The backdrop family is the easiest to explain, because the stylesheet shows the cause. Here is the one class the site uses (trimmed of its -webkit- twin):
.backdrop-blur-sm{
--tw-backdrop-blur:blur(var(--blur-sm));
backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, )
var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, )
var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, )
var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, )
var(--tw-backdrop-sepia, );
}
The class sets one property and reads nine, because one backdrop-filter declaration has to cover every utility that could combine with it (backdrop-brightness-50, backdrop-sepia, and so on). Using the one class registers all nine variables, and eight of them stay at their start value forever. The rule is the same one that made the page's blur work. The cost of it is eight registrations we never needed, which is not a bug in anything. It is how the framework gets to compose utilities without a runtime.
I traced only the backdrop family to its declaration. The filter and ring families probably follow the same shape, since both are shorthand properties built from many pieces, but I did not read those rules, so that is a guess.
The blind spot in the test
One of my "live" results is wrong, and four of the "dead" ones are hiding something.
--tw-ring-offset-width reads as live on every element (8,971 of them). It is not. Its registered type is <length> and its start value is 0, and Chromium reports the computed value as 0px. My comparison is a string match, so "0px" is not "0". I took it out of the live list by hand. It is the only property in the set with that mismatch, and it is why the tally above says 9 and not 10.
--tw-space-y-reverse, --tw-divide-x-reverse, --tw-divide-y-reverse and --tw-border-style read as dead, and the rules that set them do exist. A class like space-y-4 writes --tw-space-y-reverse: 0, which is exactly the start value. A comparison against the start value cannot distinguish "set to zero" from "never set". So "never leave their starting value" is the accurate claim and "unused" is not, and at least four of the 44 are set by utilities that really are on pages.
The method also only sees what exists at load. A hover state, an open <details> or a modal could set a property that I did not trigger, and I did not try to.
What I am not going to do about it
Nothing. 3,230 bytes, 8 per cent of the stylesheet, is not a bill I can find on any page, and removing registrations Tailwind generates would mean fighting its build for a byte count nobody will measure. What the numbers are worth is the shape: a build tool that registers 53 pieces for a site that actually assembles nine of them has a long tail, and a measurement of what a framework generates is different from a measurement of what you wrote.
If you want the same view of your own site, the check is the loop above plus document.styleSheets to collect the CSSPropertyRule list. You can compare against this one by opening the home page, where the nine live ones come from, and a page with none of the demos such as the help page or pricing, where only the five typography ones are doing anything.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.