Blog

2 days ago

Pretext Does What CSS Can't — Measuring Text Before the DOM Even Exists

Pretext is a new JS/TS library from Cheng Lou (React core, react-motion, Midjourney) that calculates multiline text height without DOM reflow. It splits work into a one-time prepare() pass via off-screen canvas, then a pure-arithmetic layout() hot path that runs in ~0.09ms. The result: accurate pre-render height prediction for virtualized lists, chat UIs, and canvas renderers — plus layout primitives CSS literally doesn't have, like finding the minimum width for a block of text at a fixed line count. Solid i18n, rigorous accuracy testing, 7k+ GitHub stars in days. Still early: no SSR, system-ui is broken on macOS, and the 500x benchmark is the author's own caveat.

Source: HackerNoon →


Share

BTCBTC
$68,104.00
0.27%
ETHETH
$2,138.44
1.77%
USDTUSDT
$1.000
0.07%
BNBBNB
$611.74
0.73%
XRPXRP
$1.35
0.12%
USDCUSDC
$1.000
0.03%
SOLSOL
$82.86
0.11%
TRXTRX
$0.315
0.75%
FIGR_HELOCFIGR_HELOC
$1.03
1.53%
DOGEDOGE
$0.0925
0.3%
USDSUSDS
$1.000
0.02%
WBTWBT
$52.07
0.25%
LEOLEO
$10.02
0.38%
ADAADA
$0.248
3.11%
BCHBCH
$455.35
3.32%
HYPEHYPE
$36.12
1.76%
LINKLINK
$8.98
2.35%
XMRXMR
$335.93
2.57%
USDEUSDE
$1.000
0.09%
XLMXLM
$0.170
0.9%