Engineering, ML, and occasional thoughts
This page uses @chenglou/pretext to measure every card's title and excerpt height before rendering any DOM. Normal web pages use getBoundingClientRect() to measure text — each call forces the browser to do a synchronous layout reflow. Pretext replaces that with pure arithmetic over cached canvas measurements.
Segments text via Intl.Segmenter, measures each word via canvas measureText(), caches widths. Done once per text.
Pure arithmetic over cached widths. Returns exact height and line count. ~0.0002ms per text. No DOM reads.
Card heights are known before render → CSS column masonry packs tightly with zero layout shift.
Hover any card to see Pretext measurement data: line count and pixel height for title + excerpt.