mdast-util-to-hast@13.2.1 · lil2 family · @itslil/lil2-mdast-util-to-hast

mdast-util-to-hast,
flat.

mdast arena to hast arena: tags, properties and enumerated values are int ids into name tables, read only where a name must leave the program.

npm install @itslil/lil2-mdast-util-to-hast
lil2 browser build versus minified upstream · Brotli-11 8.2%smaller

18,178 B upstream (Terser) → 16,688 B lil2

6.2% smallergzip-9 objective build
20.5% smallerraw objective build
0.40× the timeof upstream’s per call, Chromium 151.0.7922.34 (geometric mean)
3/3size cells smaller

Raw, gzip and Brotli each use a separate LilScript compilation targeting that objective; upstream is the smallest of Terser, esbuild and Oxc on the same API bundled for the browser.

A chat app · Playwright · phone CPUs

Streaming chats,
2.5× less CPU.

react-markdown 10.1.0 + remark-gfm, remark-math, rehype-katex → lil2 /full; main-thread time, Chromium 151
short chat (5 replies)average chat (20 replies)long chat (60 replies)
CPU while the replies stream, mid-tier phone (4×)7.1 s → 3.2 s 2.2×29.1 s → 11.5 s 2.5×1.3 min → 31.0 s 2.5×
CPU while the replies stream, low-end phone (6×)11.2 s → 4.7 s 2.4×45.9 s → 17.7 s 2.6×2.0 min → 47.4 s 2.5×
CPU while the replies stream, this machine1.6 s → 0.8 s 2.1×6.8 s → 2.7 s 2.5×17.6 s → 7.0 s 2.5×
updates slower than a frame (16.7 ms), low-end phone (6×)125 → 6 of 1,053671 → 6 of 4,6151,318 → 67 of 12,897
opening the saved chat, low-end phone (6×)417 ms → 317 ms 1.3×843 ms → 519 ms 1.6×1.77 s → 960 ms 1.8×

Measured through lil2-react-markdown, which this package is a layer of. LLM-style replies (lists, code, tables, math; about 2.5 KB each) streamed a few tokens at a time and rendered by React, finished messages memoized. Chrome's CPU throttling stands in for phones (4×: Lighthouse's mid-tier mobile; 6×: DevTools' low-end mobile); median of 2 runs, libraries alternating, fresh tab each. Every streamed update renders the same DOM as react-markdown (test/chat.test.mjs, Chromium and Firefox). Reproduce: npm run bench:chat.

lil2-micromark ✦ lil2-mdast-util-from-markdown ✦ lil2-mdast-util-to-hast ✦ lil2-remark-gfm ✦ lil2-remark-math ✦ lil2-rehype-katex ✦ lil2-remark-breaks ✦ lil2-react-markdown ✦ lil2-react-markdown + gfm ✦ lil2-react-markdown + gfm, math, KaTeX, breaks ✦ lil2-micromark ✦ lil2-mdast-util-from-markdown ✦ lil2-mdast-util-to-hast ✦ lil2-remark-gfm ✦ lil2-remark-math ✦ lil2-rehype-katex ✦ lil2-remark-breaks ✦ lil2-react-markdown ✦ lil2-react-markdown + gfm ✦ lil2-react-markdown + gfm, math, KaTeX, breaks

The lil2 family

This package,
then the stack.

Every layer of the react-markdown stack, rewritten bottom to top with ints for every id and enum and flat arrays for every tree. Each tab is one package: its size against minified upstream for each objective, its speed in real browsers, and the checks that its output equals upstream’s.

lil2-mdast-util-to-hast

mdast arena to hast arena: tags, properties and enumerated values are int ids into name tables, read only where a name must leave the program.

Rewritesmdast-util-to-hast@13.2.1 APImarkdownToHast(value, allowDangerousHtml) → hast columns BehaviourSame hast as upstream (tags, properties in order, data, positions) on 736 documents, safe and dangerous, in Node and in Chromium and Firefox. Cells3 of 3 smaller

Both builds, in this page

Live
lab.

Left is markdown. Right is lil2-react-markdown/full rendering it as you type. Race times upstream mdast-util-to-hast against lil2 on the current text, both loaded here.

The output is rendered by the shipped browser build; the race runs each side for 400 ms after a warm-up.

Browser build · minified upstream

Three objectives.
Measured separately.

Raw58,540 B

20.5% smaller than original

Terser · 73,664 B
gzip-919,061 B

6.2% smaller than original

Terser · 20,315 B
Brotli-1116,688 B

8.2% smaller than original

Terser · 18,178 B
Current LilScript versus minified original
Compiler objectiveLilScriptOriginal minifiedOriginal minifierDifference
Raw58,540 B73,664 BTerser20.5% smaller
gzip-919,061 B20,315 BTerser6.2% smaller
Brotli-1116,688 B18,178 BTerser8.2% smaller

Each LilScript row comes from a separate compilation targeting that row’s objective. Raw is uncompressed JavaScript; gzip uses level 9; Brotli uses quality 11 and window 22. For each metric, the original is the smallest result among the minifiers below. No JavaScript minifier runs after LilScript.

Every artifact, measured with all three codecs
ArtifactRawgzip-9Brotli-11
LilScript · Raw objective58,540 B19,983 B17,496 B
LilScript · gzip-9 objective59,479 B19,061 B16,667 B
LilScript · Brotli-11 objective60,190 B19,088 B16,688 B
Original · Terser 5.51.273,664 B20,315 B18,178 B
Original · esbuild 0.28.175,604 B21,906 B19,584 B
Original · Oxc vite 8.2.173,869 B20,739 B18,555 B

Browser builds on both sides: lil2’s `browser` condition and upstream bundled by esbuild 0.28.1 with the browser condition (`export {fromMarkdown} from 'mdast-util-from-markdown'; export {toHast} from 'mdast-util-to-hast'`). Upstream: mdast-util-to-hast@13.2.1. No external runtime imports. CSS, fonts, type declarations and source maps are outside these JavaScript sizes.

Measurements, hashes and settings ↗ · Commands and build receipts ↗

Real browsers · identical output first

Speed.

Chromium 151.0.7922.34 · median per call, identical output checked first
DocumentUpstreamlil2Time
chat0.665 ms0.265 ms0.40×
readme15.200 ms6.200 ms0.41×
large155.750 ms62.500 ms0.40×
load (import)4.9 ms5.1 ms1.04×
first call, cold11.1 ms10.7 ms0.96×
Firefox 153.0 · median per call, identical output checked first
DocumentUpstreamlil2Time
chat1.111 ms0.538 ms0.48×
readme31.000 ms13.000 ms0.42×
large375.000 ms123.000 ms0.33×
load (import)10.0 ms11.0 ms1.10×
first call, cold14.0 ms11.0 ms0.79×

Playwright, one fresh browser context per lane; lanes interleave and alternate order every round. Upstream is the same API bundled from npm for the browser; lil2 is the shipped browser build. Load is the module import after the file is fetched; first call is the first document, cold.

Same machine · sequential builds

Build time.

Build wall time on the same machine
Output objectiveLilScript compilationOriginal bundling + minificationOriginal minifier
Raw13.92 s0.743 sTerser
gzip-913.92 s0.743 sTerser
Brotli-114.65 s0.743 sTerser

One fresh output build per objective and minifier, run sequentially. LilScript compilation includes optimization and objective scoring with persistent caches disabled and one worker. Original time includes Node startup, esbuild bundling of installed upstream ESM, and the named minifier. It excludes building the upstream package from its original TypeScript sources. Dependency installation, tests and final file compression are excluded on both sides. These are observations on a shared machine, not a build-speed guarantee.

AMD EPYC 7763 64-Core Processor · 8 logical CPUs · 15.6 GiB RAM · Linux 7.0.0-1014-azure · Node v20.19.0. Measured 2026-10-04. Exact commands and compiler identity ↗

Install

Typed, flat,
same output.

npm install @itslil/lil2-mdast-util-to-hast