#Frontend

Mockup 147 — The Editorial Engine

Startups Reporter
3 min read

A new approach to text layout that eliminates DOM reflows and enables real-time editorial design

THE FUTURE OF TEXT LAYOUT IS NOT CSS

The web renders text through a pipeline that was designed thirty years ago for static documents. A browser loads a font, shapes the text into glyphs, measures their combined width, determines where lines break, and positions each line vertically. Every step depends on the previous one. Every step requires the rendering engine to consult its internal layout tree — a structure so expensive to maintain that browsers guard access to it behind synchronous reflow barriers that can freeze the main thread for tens of milliseconds at a time.

For a paragraph in a blog post, this pipeline is invisible. The browser loads, lays out, and paints before the reader's eye has traveled from the address bar to the first word. But the web is no longer a collection of static documents. It is a platform for applications, and those applications need to know about text in ways the original pipeline never anticipated.

A messaging application needs to know the exact height of every message bubble before rendering a virtualized list. A masonry layout needs the height of every card to position them without overlap. An editorial page needs text to flow around images, advertisements, and interactive elements. A responsive dashboard needs to resize and reflow text in real time as the user drags a panel divider.

Every one of these operations requires text measurement. And every text measurement on the web today requires a synchronous layout reflow. The cost is devastating. Measuring the height of a single text block forces the browser to recalculate the position of every element on the page. When you measure five hundred text blocks in sequence, you trigger five hundred full layout passes. This pattern, known as layout thrashing, is the single largest source of jank on the modern web. Chrome DevTools will flag it with angry red bars. Lighthouse will dock your performance score. But the developer has no alternative — CSS provides no API for computing text height without rendering it. The information is locked behind the DOM, and the DOM makes you pay for every answer.

Developers have invented increasingly desperate workarounds. Estimated heights replace real measurements with guesses, causing content to visibly jump when the guess is wrong. ResizeObserver watches elements for size changes, but it fires asynchronously and always at least one frame too late. IntersectionObserver tracks visibility but says nothing about dimensions. Content-visibility allows the browser to skip rendering off-screen elements, but it breaks scroll position and accessibility. Each workaround addresses one symptom while introducing new problems.

The CSS Shapes specification, finalized in 2014, was supposed to bring magazine-style text wrap to the web. It allows text to flow around a defined shape — a circle, an ellipse, a polygon, even an image alpha channel. On paper, it was the answer. In practice, it is remarkably limited. CSS Shapes only works with floated elements. Text can only wrap on one side of the shape. The shape must be defined statically in CSS — you cannot animate it or change it dynamically without triggering a full layout reflow. And because it operates within the browser's layout engine, you have no access to the resulting line geometry. You cannot determine where a line begins or ends, how many lines fit in a given space, or whether a line is broken by a shape.

This is the problem that Mockup 147 solves. It is an editorial layout engine that computes text geometry entirely in JavaScript, without touching the DOM. It shapes text, measures it, and determines line breaks using the same OpenType shaping engines that browsers use, but it does so in a worker thread where it cannot cause reflows. It then provides an API that lets you query the exact position of every glyph, every line, and every wrapped region.

The performance improvement is not incremental — it is categorical. 0.05ms versus 30ms. Zero reflows versus five hundred. Text becomes a first-class participant in the visual composition — not a static block, but a fluid material that adapts in real time.

Drag the orbs · Click to pause · Zero DOM reads

Try the Demo

GitHub Repository

Comments

Loading comments...