Everybody counts elements. Nobody counts attributes, which is odd, because the attributes are where the framework's opinions show up. An element census tells you what the markup is made of. An attribute census tells you who wrote it.
So I counted ours. The subject is Nakodo, 76 public pages served by Next 16, every page server rendered, no client-side navigation involved in what arrives.
How it was measured
The 76 URLs come from the sitemap. Each page is fetched with curl and a browser user agent, not read out of a browser, because my browser profile is signed in and a signed-in response is not what a visitor gets. Then every document goes through Python's html.parser with a counter per attribute name.
Three traps, all of which produce confident nonsense if you miss them:
- The React flight payload is a second copy of the page. It sits inside
<script>tags as an escaped string. Counting attributes with a regular expression over the raw bytes therefore counts most of them twice.html.parserswitches to raw text mode insidescriptandstyle, so it does not. - SVG is a different vocabulary. 34,175 of the nodes on this site are drawing nodes, and their attributes are things like
dandstroke-linejoin. Mixed into the document total they drown it. I tracked an SVG depth counter and kept the two populations apart. -
html.parserlowercases attribute names, and that is the interesting part. HTML attribute names are ASCII case-insensitive, so a parser is entitled to fold them. But the bytes on the wire are not folded, and what React actually wrote turns out to be worth a section of its own. For that part I counted the served text case-sensitively, with<script>contents removed first.
The document: 44,944 attributes under 52 names
30,322 HTML elements carry 44,944 attributes, which is 1.48 attributes per element. 4,428 of those elements, 14.6%, carry none at all.
| Attribute | Count | Attribute | Count |
|---|---|---|---|
class | 20,685 | data-precedence | 152 |
href | 6,538 | lang | 153 |
content | 1,924 | style | 95 |
rel | 1,739 | tabindex | 81 |
id | 1,238 | aria-live | 80 |
src | 1,215 | data-state | 79 |
type | 1,095 | title | 79 |
async | 1,139 | charset | 76 |
name | 977 | fetchpriority | 76 |
property | 949 | sizes | 76 |
as | 816 | nomodule | 76 |
aria-label | 786 | hidden | 76 |
crossorigin | 740 | aria-haspopup | 76 |
data-slot | 563 | aria-expanded | 76 |
aria-labelledby | 527 | aria-atomic | 76 |
data-variant | 489 | aria-relevant | 76 |
data-size | 489 | data-dpl-id | 76 |
scope | 469 | data-react-aria-top-layer | 76 |
target | 385 | aria-current | 71 |
aria-hidden | 290 | datetime | 63 |
The remaining twelve are value, for, placeholder, inputmode, autocomplete (36 each), role (10), aria-describedby (5), aria-checked (3), and then action, maxlength, data-gust-around and open at one occurrence each on the whole site.
class is 46.0% of every attribute in the document. class and href together are 60.6%. The top five names are 71.5%. An attribute census of a Tailwind site is mostly a census of one attribute, and I say that as a defence of neither position: it is simply the shape.
Per page the median is 40 distinct attribute names, and the range is narrow. The privacy notice and the terms are lowest at 36, which is what a page made of headings, paragraphs and links looks like. The sponsorship cost calculator is highest at 46, because it has inputs, a radio group and a table. 35 of the 52 names appear on all 76 pages, which means the shared shell accounts for two thirds of the vocabulary and the content accounts for the rest.
Not one bare boolean
hidden, async, nomodule and open are boolean attributes. In HTML you write them with no value. On this site there is not a single bare attribute anywhere in 44,944:
<script async="" src="..."></script> <div hidden=""></div> <details class="group" open=""></details> That is React, serialising every boolean prop as an empty string, and it is correct: for a boolean attribute, present-with-empty-value and present-with-no-value mean exactly the same thing to a parser. It costs two bytes per occurrence, 2,584 bytes across the site, since 1,292 of the attributes are booleans, and it is the kind of thing you only notice when you have the counter in front of you.
The one place it is not an empty string is the single data-* attribute I wrote myself. In the JSX it is written with no value at all:
<div data-gust-around className="relative lg:col-span-7"> React has no way to know that is meant as a boolean, because data-* attributes are not in its property table, so it writes the string "true". The flight payload in the same response carries it as a JSON boolean. It is a hook for a querySelector in the leaf animation on the home page, and it is the only attribute on the public site that appears exactly once and is read by our own code.
Eleven attributes are served with a capital letter
Counted case-sensitively over the served markup, eleven attribute names contain an uppercase letter:
| Name | Count | Why |
|---|---|---|
viewBox | 2,656 | SVG, must be camelCase |
preserveAspectRatio | 1,520 | SVG, must be camelCase |
patternUnits | 82 | SVG, must be camelCase |
patternTransform | 82 | SVG, must be camelCase |
charSet | 76 | HTML, works by accident |
fetchPriority | 76 | HTML, works by accident |
dateTime | 63 | HTML, works by accident |
inputMode | 36 | HTML, works by accident |
autoComplete | 36 | HTML, works by accident |
pathLength | 3 | SVG, must be camelCase |
maxLength | 1 | HTML, works by accident |
The split is the whole story. SVG attribute names are case-sensitive, so viewBox has to be spelled that way or the browser ignores it. HTML attribute names are case-insensitive, so charSet="utf-8" and charset="utf-8" are the same attribute, and React simply prints the prop name it was given rather than converting it. Six of our eleven are in the second category: they are React prop spellings leaking into the document, and they work because the HTML parser does not care.
Except React does convert some of them. In the rendered markup the drawings use stroke-width 10,212 times. In the flight payload in the same response, the same attribute appears as strokeWidth 9,924 times. Also strokeLinecap 1,927, strokeLinejoin 1,602, clipPath 158, textAnchor 153. So there is a conversion table, it covers the hyphenated SVG presentation attributes, and it does not cover charSet, which is a case-insensitive attribute where nobody needed it to.
2,066 aria attributes and ten uses of role
Eleven distinct aria-* names appear in the document, 2,066 times in total, plus 2,581 aria-hidden on SVG roots, which is every decorative drawing on the site declaring itself decorative. That is 4,647 accessibility attributes.
role appears ten times, on two pages. Five role="tooltip" and one role="img" on the home page, one role="radiogroup" and three role="radio" on the sponsorship calculator, where the currency switch is a real radio group and not three buttons pretending.
Ten against 4,647 is the ratio I would want. role overrides the semantics the browser already derived from the element, so a high count usually means somebody is relabelling divs. A high aria-label count with a near-zero role count means the names are being supplied to elements that already had the right role. The engagement rate calculator is a good one to inspect: every input has a <label for>, so the 36 for attributes and the 36 ids pair up and nothing needs naming by hand.
A few other single-value attributes worth printing, because a census is also a uniformity test:
- All 385
targetattributes are_blank. There is no other target value on the site. - All 81
tabindexattributes are-1. There is no positive tabindex anywhere, which is the rule I would most want to hold and the easiest one to break by accident. - All 71
aria-currentattributes arepage. - The 469
scopeattributes are 313rowand 156col. - All 816
asattributes are preload hints: 740 fonts and 76 scripts.
The drawings: 91,035 attributes under 41 names
| Attribute | Count | Attribute | Count |
|---|---|---|---|
d | 24,832 | cx cy | 494 each |
fill | 17,448 | xmlns | 492 |
stroke | 10,796 | rx | 275 |
stroke-width | 10,212 | r | 260 |
transform | 5,300 | ry | 254 |
class | 3,513 | opacity | 198 |
viewbox | 2,656 | x y | 195 each |
aria-hidden | 2,581 | id | 162 |
stroke-linecap | 2,269 | vector-effect | 90 |
stroke-linejoin | 1,944 | clip-path | 80 |
focusable | 1,604 | overflow | 76 |
preserveaspectratio | 1,520 | visibility | 45 |
style | 996 | pathlength | 3 |
width height | 775 each | text-anchor font-size | 1 each |
34,175 drawing nodes carry 91,035 attributes, 2.66 each, which is nearly twice the rate of the document. That is what vector art is: a few node types with a lot of numbers on them.
The d attribute alone is 8.3 MB of the 37.9 MB this site serves across all 76 pages. One attribute name, 22% of the bytes. It is also the cheapest 22% to compress, because path data is thousands of repetitions of M, c, l and two decimal places, which is why the pages arrive at around a tenth of that over the wire. You can see the biggest concentration of it in the drawn landscape at the bottom of any page.
What I take from this
- The uniformity findings are the useful output. 385
targets all_blank, 81tabindexes all-1, 71aria-currents allpage. None of that is enforced by anything today, and all three are one-line assertions over fetched pages. A census is a snapshot; a test is the thing that keeps the snapshot true. - Six attributes on one page each is a map of the hand-written code.
action,maxlength,data-gust-aroundandaria-describedbyare all on the home page, andaria-checkedis on one calculator. 63 of our 76 pages come out of a content registry, and they contribute no unique attributes at all. The irregularity lives exactly where the hand-written pages are, which is the same conclusion I keep reaching from different directions. -
charSetis harmless and I would still rather it werecharset. Not because it breaks anything, but because an attribute spelled in a JavaScript convention in a served document is a small lie about what the document is. Next writes that one, so this is an observation rather than a task. - Leave
classalone. 46% of the document's attributes being one name looks like a problem and is not: the alternative is a stylesheet with more selectors, and the bytes compress against each other because the same utility strings recur on every page.
If you want to run this on your own site, the only two things that matter are parsing with something that honours CDATA inside script, and deciding before you start whether you are counting the document or the drawings. Those two decisions moved my headline number by a factor of three.
