Skip to content
aadhar.sh/garage/html-over-js
Address
aadhar.shGarageTrading page scripts for CSS changes keyboards more than bytes

Trading page scripts for CSS changes keyboards more than bytes

Aleth Gueguen's Go fast? Go web native asks whether the script behind an interactive element can give way to modern HTML. Five stacked PRs here swap page scripts for HTML and CSS on 22 pages and call the result functionally identical. This page shows where that holds, where the line between the two blurs, and what neither can do, with every piece built both ways so you can press them side by side.

The trade, both ways

HTML and CSSJS
script off or failingworksthe control does nothing; a built table or filter is empty
keyboarda radio group is 1 Tab stop, arrow keys move the pick, Enter doesn't pickbuttons: 3 to 8 Tab stops, Enter picks
screen readerradio [checked]button [pressed]
bytes on the wirea tie, within a few hundred bytes a page
work per press, 19 rowsa tie, 1.3 ms or less
work per press, 4,750 rows:has() does 2.5x in Chromium, 11.8x in WebKitrebuilds only the rows it keeps
the XP lookthe same inside the page; neither reaches what the browser draws outside it
timers, fetch, storage, the pointer, typed textcan'tcan
dialog backdrop click on Safari 26closedby arrives in Safari 27.3a hand-written check

HTML and CSS win where a control has a small, fixed set of states and the browser draws it inside the page. JS wins where the state lives somewhere CSS can't read: a timer, the network, storage, the pointer, or text a reader typed.

Why the code was JS in the first place

No commit says, so this is what the history shows.

The same control with and without script

Each bench runs one control three ways: this site's JS, that same markup with its script removed (what a reader gets when the script fails or JavaScript is off), and the HTML twin.

Tabs, from /garage/gpt56

JS twin: buttons, aria-pressed, a click handler that rewrites the panel

performance workbench / three checks

CHECK 01 · FIRST PAINT

Pick a layer of the tune-up. The readout is deliberately small: one concrete decision, one thing to measure, one thing that can still go wrong.

Make the first frame honest

Keep the desktop and window geometry in the document, preload the shared Luna sheet, and defer the shell behavior. The browser paints the identity before JavaScript has had a chance to help.

count4
signal0.00
prooftrace

JS, script off: the first panel shows; the buttons do nothing

performance workbench / three checks

CHECK 01 · FIRST PAINT

Pick a layer of the tune-up. The readout is deliberately small: one concrete decision, one thing to measure, one thing that can still go wrong.

Make the first frame honest

Keep the desktop and window geometry in the document, preload the shared Luna sheet, and defer the shell behavior. The browser paints the identity before JavaScript has had a chance to help.

count4
signal0.00
prooftrace

HTML twin: radios in a fieldset, :has() picks the panel

performance workbench / three checks

CHECK 01 · FIRST PAINTCHECK 02 · BYTESCHECK 03 · SHIP

Pick a layer of the tune-up. The readout is deliberately small: one concrete decision, one thing to measure, one thing that can still go wrong.

choose a performance check

Make the first frame honest

Keep the desktop and window geometry in the document, preload the shared Luna sheet, and defer the shell behavior. The browser paints the identity before JavaScript has had a chance to help.

Give every byte a stable home

Hash the thumbnails, let static assets answer at the edge, and use one cacheable Luna sheet. If a byte changes, its URL or cache key should tell the truth.

Prove the fast build shipped

Run the invariant tripwires, minify only the earned shell assets, keep the readable twins, and curl the routes. A green deploy is a claim with evidence attached.

count4
signal0.00
prooftrace
count3
signal35 KB
proofbudget
count44
signal64.74 KB
prooforacle

A filter over 19 rows, from /garage/hidden-flags

JS twin: builds the buttons and the table, rebuilds the table on each click

JS, script off: the script builds the filters and the rows, so nothing shows

HTML twin: 19 rows in the markup, :has() hides the rest

filter the flags
19 hidden flags5 of 19 hidden flags4 of 19 hidden flags2 of 19 hidden flags6 of 19 hidden flags3 of 19 hidden flags3 of 19 hidden flags1 of 19 hidden flags
flagaliasgroupwhat it says it does
--experimental-new-config--x-new-configconfig[experimental] Use cloudflare.config.ts and wrangler.config.ts
--experimental-cf-build-output--x-cf-build-outputconfig[experimental] Emit a Build Output Specification directory under .cloudflare/output/ (requires --experimental-new-config)
--experimental-auto-create--x-auto-createreleaseAutomatically provision draft bindings with new resources
--experimental-provisionreleaseNo description in the definition. Pinned off here alongside auto-create, because no deploy path on this account may create resources.
--max-versionsreleaseMaximum allowed versions to select. Defaults to 2, and its own comment says the limit is server side.
--experimental-deploy-helpers--x-deploy-helpersreleaseExperimental: Gates refactored deploy/upload path
--experimental-include-runtime--x-include-runtimetypesThe path of the generated runtime types file
--enable-containerscontainersWhether to build and enable containers during development
--config-file-FcontainersSets ssh -F: specify an alternative per-user ssh configuration file
--identity-file-icontainersSets ssh -i: select a file from which the identity for public key authentication is read
--escape-charcontainersSets ssh -e: set the escape character for sessions with a pty
--log-filecontainersSets ssh -E: append debug logs to log_file instead of standard error
--mac-speccontainersSets ssh -m: a comma separated list of message authentication code algorithms, in order of preference
--delegate-c3--c3setupDelegate to Create Cloudflare CLI (C3)
--install-wranglersetupInstall Wrangler during project setup
--completion-messagesetupDisplay a message with deployment details after wrangler setup is complete
--node-compatlegacyEnable Node.js compatibility
--site-includelegacyWorkers Sites: gitignore style patterns; only matched items will be uploaded
--site-excludelegacyWorkers Sites: gitignore style patterns; matched items are skipped

A modal, from Notepad

JS twin: a template, showModal(), and a hand-written backdrop check

JS, script off: the button does nothing

HTML twin: command=show-modal and closedby=any

About Notepad

Notepad, a resto-mod of the Windows XP app.

This is a real text field: edit it however you like. Nothing saves, so a reload restores my canonical version. The writing here is always in flux.

A sticky note, from /writing

JS: the close box is a link; a click handler stops it and calls hidePopover()

todo.txt✕

A popover note with an XP close box.

JS, script off: the close box is still a link, to /writing

todo.txt✕

A popover note with an XP close box.

HTML twin: popovertargetaction="hide" on a button

todo.txt

A popover note with an XP close box.

A tree, from /access

JS: buttons with aria-expanded; a click handler hides the branch

    • Tahoma
    • Verdana
    • Trebuchet MS
    • Luna blue
    • Olive green
    • Silver

JS, script off: the buttons do nothing

    • Tahoma
    • Verdana
    • Trebuchet MS
    • Luna blue
    • Olive green
    • Silver

HTML twin: details and summary, CSS draws the + and -

  • Fonts
    • Tahoma
    • Verdana
    • Trebuchet MS
  • Colours
    • Luna blue
    • Olive green
    • Silver

Where the line blurs

Each piece below is built twice. The badge says where it falls: CSS can do it now, CSS can do it where your browser supports the feature, or only script can.

Fade in on open CSS now

JS

HTML and CSS

Faded in by @starting-style.

@starting-style gives an element a style to transition from on its first frame, so a fade on open needs no class swap.

Count what's ticked CSS now

JS

2 of 3 on

HTML and CSS

A CSS counter adds one per :checked box. It can count; it can't do arithmetic on what it counts.

A scroll progress bar works in this browsernot in this browser

JS

Line 1 of a long note.

Line 2 of a long note.

Line 3 of a long note.

Line 4 of a long note.

Line 5 of a long note.

Line 6 of a long note.

Line 7 of a long note.

Line 8 of a long note.

Line 9 of a long note.

Line 10 of a long note.

Line 11 of a long note.

Line 12 of a long note.

Line 13 of a long note.

Line 14 of a long note.

HTML and CSS

Line 1 of a long note.

Line 2 of a long note.

Line 3 of a long note.

Line 4 of a long note.

Line 5 of a long note.

Line 6 of a long note.

Line 7 of a long note.

Line 8 of a long note.

Line 9 of a long note.

Line 10 of a long note.

Line 11 of a long note.

Line 12 of a long note.

Line 13 of a long note.

Line 14 of a long note.

animation-timeline: scroll() drives the bar from the scroller's position. Where it's missing, the bar stays empty and the script is the only way.

A text box that grows works in this browsernot in this browser

JS

HTML and CSS

field-sizing: content sizes the box to what's in it. Elsewhere it keeps one row and scrolls.

Count the characters typed JS only

JS

4 characters

HTML and CSS

no count

CSS can style a field, size it to its text and flag it invalid. It can't read the text, so it can't say how long it is.

Show a slider's value JS only

JS

40

HTML and CSS

40

CSS can style the track and the thumb. The number beside it stays where the page started, because CSS can't read a moved slider.

A tooltip that follows the cursor JS only

JS

Move the pointer herex, y

HTML and CSS

Move the pointer herepinned under the box

CSS can pin a tooltip to an element and delay it. Following the pointer, and printing where it is, takes script.

What every JS-only piece shares: it reads a value that changes after the page loads (typed text, a slider's position, the pointer), and CSS can't read values, only states like :checked and :user-invalid.

Does native HTML break the XP look?

The worry on this site: browsers draw their controls in 2026's style. Each pair shows a control as the browser ships it, then the same element dressed in Luna.

A dialog holds

as the browser draws it

A dialog as the browser ships it.

in Luna

Display Properties

The same element as the plain one, with a title bar and Luna's frame.

The box and its backdrop are page content, so a title bar and a frame make it a window.

A disclosure holds

as the browser draws it

Fonts

Tahoma, Verdana

in Luna

  • Fonts
    • Tahoma
    • Verdana

The triangle is a ::marker. Hide it and CSS draws XP's + and -.

A focus ring holds

as the browser draws it

in Luna

Tab onto each. :focus-visible draws XP's dotted rectangle inside the face.

Radios and a checkbox holds

as the browser draws it

in Luna

appearance: none hands the box to CSS. The keyboard, the form value and the screen reader stay native.

A drop-down Chromium only

as the browser draws it

in Luna

appearance: base-select lets CSS draw the open list too, in Chromium. Elsewhere the closed box takes CSS and the list that opens is the system's.

A file button holds

as the browser draws it

in Luna

::file-selector-button takes the XP button. The file dialog it opens is the system's, with script or without.

A validation message browser's own

as the browser draws it

in Luna

Type at least 3 letters.

Type one letter and press Ask. The bubble on the left is drawn above the page, where no stylesheet reaches. The balloon needs novalidate, so stopping a short question there takes script.

A tooltip browser's own

as the browser draws it

in Luna

Shows the desktop

A title is drawn by the system. A CSS tooltip holds the look; following the cursor, as Luna's do, takes script.

Whatever the browser draws inside the page takes Luna. What it draws outside doesn't, and script can only replace those, never restyle them:

drawn by the browserHTML and CSSJS
the validation bubblecan't style itcan turn it off and draw its own balloon
a title tooltipcan't style itcan drop it and draw its own
a select's open listcan style it in Chromium, with appearance: base-selectcan replace the select with its own list
the file dialog, the print dialog, permission prompts, autofillneither: these belong to the browser and the operating system

The numbers

Every twin was screenshotted at load and after every press in Chromium 158, Firefox 159 and WebKit 27.2 with bun run twin:bench, which first checks it can tell a twin from itself (0 of 5 states differ) and from a 0.3 px change (5 of 5).

twin pairstateschromium 158.0.8127.89: identical states, most pixels apartfirefox 159.0: identical states, most pixels apartwebkit 27.2: identical states, most pixels apart
tabs52 of 5, 2245 px2 of 5, 2232 px2 of 5, 2250 px
filter99 of 9, 0 px9 of 9, 0 px5 of 9, 32 px
sibling99 of 9, 0 px9 of 9, 0 px5 of 9, 32 px
sibling-fs99 of 9, 0 px9 of 9, 0 px5 of 9, 32 px
dialog66 of 6, 0 px6 of 6, 0 px6 of 6, 0 px
popover22 of 2, 0 px2 of 2, 0 px2 of 2, 0 px
twinTab stopsArrowRight picksSpace picksEnter picksreload keeps the pickwith JS off
tabs-jschromium 4
firefox 4
webkit 1
noyesyesnoMake the first frame honest
tabs-radiochromium 2
firefox 2
webkit 1
yesyesnochromium no
firefox yes
webkit no
Make the first frame honest
filter-jschromium 8
firefox 9
webkit 1
noyesyesno(no count) / 0 rows / 0 filters
filter-radiochromium 1
firefox 2
webkit 1
yesyesnochromium no
firefox yes
webkit no
19 hidden flags / 19 rows / 8 filters
filter-siblingchromium 1
firefox 2
webkit 1
yesyesnochromium no
firefox yes
webkit no
19 hidden flags / 19 rows / 8 filters
filter-sibling-fschromium 1
firefox 2
webkit 1
yesyesnochromium no
firefox yes
webkit no
19 hidden flags / 19 rows / 8 filters
PRwhat it convertspagesinline scriptsinline script, rawdocuments, compressed
1889static tables and server-rendered /restore44 to 330.2 KB to 28.9 KB43.4 KB to 45.6 KB +2,252 B
1890@supports and @starting-style46 to 567.7 KB to 65.9 KB59.5 KB to 59.5 KB -32 B
1891:has() state machines813 to 435.5 KB to 6.8 KB94.9 KB to 94.6 KB -254 B
1892native dialogs, popovers, forms, links512 to 1131.2 KB to 30.3 KB97.4 KB to 97.4 KB -40 B
1893/lens: invokers, details, forms10 to 00.0 KB to 0.0 KB19.6 KB to 19.7 KB +129 B

PR 1891 removes 28.7 KB of raw script and its pages shrink by 254 B, because brotli had already squeezed the script.

twin pairJS twin, page brotliHTML twin, page brotlichangeJS twin min CSS + HTML + JSHTML twin min CSS + HTML
tabs1784 B1721 B-63 B247 + 1607 + 16171052 + 2481
filter1942 B1990 B+48 B389 + 202 + 41512848 + 4681
filter, sibling1942 B2081 B+139 B389 + 202 + 41513356 + 4893
filter, sibling in fieldset1942 B2098 B+156 B389 + 202 + 41513504 + 4895
dialog903 B639 B-264 B0 + 71 + 13340 + 717
popover451 B379 B-72 B0 + 260 + 1720 + 301
twinchromiumchromium 4xfirefoxwebkit
950 rows, JS5.31 ms p90 23.5220.7 ms p90 93.576.51 ms p90 24.5218.11 ms p90 84.3
950 rows, :has()13.56 ms p90 34.6455.74 ms p90 140.5913.18 ms p90 32.3872.19 ms p90 174.68
950 rows, sibling7.2 ms p90 30.125.47 ms p90 114.756.71 ms p90 27.8624.37 ms p90 96.78
4,750 rows, JS25.22 ms p90 127.42101.06 ms p90 517.5532.46 ms p90 136.5109.6 ms p90 416.38
4,750 rows, :has()63.42 ms p90 172.16272.87 ms p90 721.8372.3 ms p90 264.921289.69 ms p90 2237.68
4,750 rows, sibling30.59 ms p90 144.4121.88 ms p90 596.8135.7 ms p90 241.1565.43 ms p90 1151.62
Every page in the stack, what has to stay script, offscreen rows, the quiz and browser support
PRpagechromium at loadfirefox at loadwebkit at loadChromium, presses that match
1889/garage/ig-prepsamesamesame
1889/garage/resamplesamesamesame
1889/garage/typed-configsamesamesame2 of 2
1889/restoresamesame735 px0 of 0
1890/garage/scrollsamesamesame0 of 0
1890/garage/safari27samesamesame1 of 1
1890/garage/masonrychanges on reloadchanges on reloadsame0 of 0
1890/pixel-peeper7 pxsamesame0 of 0
1891/garage/gpt5620,681 px18,902 pxheight differs0 of 0
1891/garage/octanesamesame1,861 px0 of 0
1891/garage/hidden-flagssamesamesame1 of 8
1891/garage/useragentsamesamesame0 of 4
1891/lwe/teesamesameheight differs0 of 5
1891/lwe/fusesamesame8,460 px3 of 5
1891/lwe/leansamesame24,409 px6 of 10
1891/coffeesamesamesame10 of 10
1892/changes on reloadchanges on reloadsame
1892/writingsamesamesame
1892/garage/chunkssamesamesame3 of 3
1892/accesssamesamesame3 of 3
1892/lwe/knotssamesame98 px0 of 0
1893/lens199,797 px162,913 pxheight differs0 of 1
what the script doeswhat replaces itwhere the stack uses itsame for a reader?
writes a constant table or list into the pagethe rows, written in the markupig-prep, resample, useragent, /restoreyes, once the rows exist only once
calls CSS.supports() to colour a chipan @supports rulescroll, safari27, masonryyes, and right at first paint
buttons with aria-pressed swap a panel or filter rowsradios in a fieldset, :has() picks what showsgpt56, octane, hidden-flags, useragent, tee, fuse, lean, masonrypixels yes, keyboard no
builds a dialog, calls showModal(), checks backdrop clicks by handa static dialog, command="show-modal", closedby="any"Notepad, /access, Lens, the WebMCP gateyes where closedby ships
calls hidePopover() from a close linkpopovertargetaction="hide" on a buttonNotepad's popover notesyes, and the pixels match
wherereadcan go wholecan go in partstays script
shell modules: nav, tooltips, Notepad, photos, Run13 modules, about 6,000 linesabout 150 linesabout 5,850 lines
Garage page scripts4171321
LWE, home, /access, Pixel Peeper244416
read first, by hand8314
every page script73141841
twinchromiumchromium 4xfirefoxwebkit
tabs, JS0.54 ms p90 0.961.17 ms p90 1.530.28 ms p90 0.380.44 ms p90 0.66
tabs, radios0.86 ms p90 1.411.38 ms p90 1.740.5 ms p90 0.60.72 ms p90 0.78
control: 20 ms busy-wait in the click handler, added+20.1 ms+20.5 ms+20.2 ms+20.2 ms
control: 20 ms busy-wait on the radio's change, added+20.2 ms+20.1 ms+20.2 ms+20.1 ms
19 rows, JS1.04 ms p90 1.791.83 ms p90 3.950.82 ms p90 1.020.86 ms p90 2.12
19 rows, :has()1.28 ms p90 2.512.45 ms p90 4.121.26 ms p90 1.581.27 ms p90 2.66
19 rows, sibling1 ms p90 1.691.87 ms p90 3.640.71 ms p90 1.180.96 ms p90 2.2
variantchromiumchromium 4xfirefoxwebkitlast row's cells
4,750 rows, JS25.22 ms101.06 ms32.46 ms109.6 msrendered
JS, content-visibility25.18 ms96.61 ms30.11 ms87.45 msrendered
JS, grid rows26.15 ms105.14 ms27.99 ms89.69 msrendered
JS, grid rows + c-v4.82 ms19.5 ms16.36 ms32.15 msskipped
4,750 rows, :has()63.42 ms272.87 ms72.3 ms1289.69 msrendered
:has(), content-visibility67.49 ms308.97 ms67.94 ms1293.5 msrendered
:has(), grid rows59.96 ms269.52 ms71.31 ms1239.91 msrendered
:has(), grid rows + c-v31.59 ms140.35 ms56 ms1276.65 msskipped
4,750 rows, sibling30.59 ms121.88 ms35.7 ms565.43 msrendered
sibling, content-visibility34.52 ms146.39 ms38.6 ms811.31 msrendered
sibling, grid rows29.88 ms121.28 ms33.45 ms540.7 msrendered
sibling, grid rows + c-v10.94 ms43.24 ms26.16 ms365.97 msskipped

The understanding check at the foot of this page keeps script for its fetch and best score. PR 1927 runs the rest in CSS on /garage/scroll and gives up answer lock-in and the best score.

whatscript quizCSS quiz
/garage/scroll's quiz file, brotli2,064 B2,592 B
all 31 garage quiz files, brotli58,300 B74,252 B
quiz.css, brotli804 B1,017 B
quiz.js, brotli2,393 B1,645 B
an answer locks once checkedyesno, a radio stays changeable
best score keptyesno
"nearly clean" for one missyesno
answered questionsreplaced in placestay stacked

First versions from MDN browser-compat-data, read on 2026-11-27. This site supports the current Chrome, Safari 26 and Firefox 150.

featureChromeFirefoxSafariwhat it replaced
@supports28229CSS.supports() calls
@supports selector()836914.1the :heading probe
:has()10512115.4the click handler that picks a panel
:nth-child(odd of S)1111139re-striping rows the script rebuilt
:focus-visible868515.4the focus ring a button drew for free
popovertarget, popovertargetaction11412517hidePopover()
command, commandfor13514426.2showModal() on click
dialog closedby13414127.3the hand-written backdrop check

What the oracle caught

  • gpt56 showed all three readouts at once: .sol-ro{display:none} lost to a later .readouts{display:grid} of the same specificity.
  • hidden-flags striped unevenly when filtered: hidden rows still count for :nth-child(odd); :nth-child(odd of [data-g=config]) counts only the rows a filter keeps.
  • fuse's first demo threw on every visit: the build minified its inline script as a module, and a block-scoped function collided with a mangled name.

Before the stack merges

  • 1890 leaves masonry's radio checked on browsers without grid-lanes, Safari 26 and Firefox; the old code disabled it.
  • 1893 needs /lens* out of the speculation rules, or hovering a chip prerenders an inspection of a third-party site.
  • 1889, 1891 and 1892 are ready.
garagewatching2026-11-27