9. Live in-browser comparison (site, phase 7)

@avarok/glance@0.1.0Updated 2 min readView as markdown

Project rule of 2026-11-29: when the reference and glance both run in a browser, the site ships a live comparison that loads nothing until the visitor clicks. Both engines run in the page, so glance qualifies.

9.1 Measure first (bench/browser/)

  • Chromium via Playwright; same input; each engine on its own fresh copy of the page; one at a time; random order; median of at least 7. Record cold (fetch + compile + first run), warm (second run on an already-instantiated engine), script size, and equivalence: the same rule ids in violations/incomplete and the same failing node targets per rule.
  • Pages: one small (the ~300-element app page) and one large (a long documentation page we can license, e.g. our own generated docs page or a CC-BY-SA page saved with attribution). Neither is chosen for flattering results; both are listed with element counts.
  • No demo if glance is not faster on the warm path. If warm is faster but cold is slower, show both numbers. The record and the decision go in REFRESH.md.

9.2 Why iframes, not Web Workers

Both engines read the live DOM, styles and layout, which a Web Worker cannot see. Each run therefore happens in its own sandboxed same-origin iframe holding a fresh copy of the sample page, created only after the click. The engine script is loaded into that iframe with a <script src> (served from our origin, no inline script), so CSP needs only 'wasm-unsafe-eval' for glance's module.

9.3 The competitor's build

axe-core 4.14.1's published axe.min.js, fetched from the npm registry at site build time, checked against a pinned integrity hash, and served unmodified as a separate file. It is never committed and never read. The modal footer states that it is axe-core 4.14.1, © Deque Systems, MPL-2.0, and links to its source. It is credited neutrally.

9.4 The modal

An accessible dialog (role=dialog, aria-labelledby, focus trap, Esc closes, focus returns to the button) with zero violations when open, audited with glance and with the reference. Each pane shows the counts of violations, passes and incomplete, "download + start-up" and "run" times, then the warm median; "Run again" reruns warm. An equivalence line compares rule ids and failing targets. The modal says the numbers were "measured on your device, one at a time, same page".