Automating the Annoying: Lessons from Extracting Loaders Directly from the DOM
RenderCon Kenya 2026 — ALX The Piano, Westlands, Nairobi — Oct 2026
Skeleton loaders are one of the cheapest ways to make an interface feel faster. They are also one of the easiest things to let rot. A skeleton is a second version of the UI, and that second version has to be maintained alongside the first. This talk is about removing that second copy: generating skeletons directly from the rendered DOM.
The skeleton problem
A skeleton is a simplified placeholder that mirrors the layout of the content that is about to appear. It gives the user a preview of the page structure instead of a blank screen or a spinner.
The trouble starts when the real UI changes. Consider a UserCard with an avatar, a name, a headline, and a Connect button. Its hand-written skeleton has to repeat the same structure with placeholder boxes:
function UserCardSkeleton() {
return (
<div className="user-card-skeleton">
<div className="avatar-skeleton" />
<div className="content-skeleton">
<div className="name-skeleton" />
<div className="headline-skeleton" />
<div className="connect-skeleton" />
</div>
</div>
);
}
When the product adds a Message button, the real component changes and the skeleton has to change too. Now there are two sources of truth, and they drift.
There is an accessibility problem as well. A skeleton made of the real markup would be read out as content: a p announced as text, a button announced as a control you can tab to. A skeleton must look like a loading state without pretending to be the real thing.
What the generator has to get right
Four objectives shaped the design:
- The source should be the only thing you maintain. Skeletons should be generated from the source, not maintained separately.
- Generated skeletons should still be customizable. When the generated result is not exactly right, you should be able to adjust it without maintaining a separate skeleton.
- The generated skeleton should represent the rendered UI. What matters is not just the source markup, but what the component looks like when it renders.
- The generated result should actually be a skeleton. Meaningful content from the source should not leak into the generated output.
Three ways to generate skeletons
The talk compares three approaches.
1. Dev-time generation with a real browser
Render the actual application, let a developer point at the component, and extract its layout from the live DOM. This has the highest fidelity because it is the real UI, but the capture is manual.
2. Build-time generation with a headless browser
Use the same rendering approach, but run it without a visible browser. This fits into a build pipeline, but it is slower and needs fixtures for anything that is not reachable without state, authentication, or interaction.
3. Runtime generation
Extract the layout information in the browser at runtime. There is no build step, but the browser pays the cost on every user's device.
The tradeoff is fidelity versus build speed versus complexity. The talk focuses on making the dev-time approach practical: a development-only capture flow that avoids the cost of a headless browser while still working on the real rendered component.
SkullMaster: mark, click, generate
SkullMaster asks the developer for three small changes: a marker, an import, and a loading branch.
import { markAsSkull, Skeleton } from "skullmaster/react";
function UserCardPage({ user, isLoading }) {
if (isLoading) {
return <Skeleton name="UserCard" />;
}
return (
<article {...markAsSkull("UserCard")} className="user-card">
<img className="avatar" src={user.avatar} alt={user.name} />
<div className="content">
<h3>{user.name}</h3>
<p>{user.headline}</p>
<button onClick={connect}>Connect</button>
</div>
</article>
);
}
In development, a script injects a capture mode. The developer opens the site, clicks the fully rendered component, and the script reads the runtime information off that click. The payload goes to a local dev server:
flowchart LR
A["Open the app"] --> B["Click the rendered component"]
B --> C["Dev-only script captures the HTML"]
C --> D["Skullmaster dev server :8008"]
D --> E["Transform the HTML payload"]
E --> F["skeletons/UserCardSkeleton.tsx"]
E --> G["Update registry.tsx"]
The server turns the captured markup into a React component, saves it under skeletons/, and updates the registry. There is no headless browser and no fixture setup: the component is captured with the state and data that are already on screen.
Turning real markup into a skeleton
There are two ways to turn the captured markup into a skeleton.
The first is to replace everything with divs sized from getBoundingClientRect(). That produces a static picture of one screen size, and it is wrong as soon as the layout changes.
The second keeps the elements semantically the same, then neutralizes them:
<>
<img className="avatar" alt="" aria-hidden="true" />
<h3 className="title" aria-hidden="true" />
<button className="connect" disabled />
</>
For some use cases, changing the tags is a deal breaker. The generated result still behaves like a skeleton because the ARIA attributes and the stripped content do the work.
From there, the generator applies a set of transformations:
- Text becomes placeholder blocks. Every text node is replaced with a block that has approximately the same visual footprint. Names, prices, and labels never reach the generated skeleton.
- Images become empty placeholders. The source image is replaced with a generated SVG placeholder, keeping the geometry and corner radius.
- Interactivity is removed. Links and buttons stay in the tree for layout, but are hidden from assistive technology and removed from the tab order.
- Form controls become inert. Inputs keep their geometry and type, but are disabled, hidden from assistive technology, and opted out of password-manager autofill.
- The root is marked as a loading state. The generated root gets
role="status",aria-live="polite",aria-busy="true", and adata-skullmastermarker. - Insignificant elements are removed. Layout-only wrappers that contribute no meaningful visual structure are dropped.
The result is a skeleton that is visually faithful to the rendered UI, but does not expose the real content.
Customization without editing generated files
Editing a generated skeleton directly breaks the single source of truth, and the fix disappears the next time the skeleton is generated. SkullMaster puts the correction in the source instead.
Data attributes are the escape hatch. They ride along in the DOM for free, and only the generator reads them.
data-depth="-1"keeps an element in the layout but makes it transparent. Remove it, or set another depth, on elements that should render a visible bone.data-skip-skullremoves an element and its whole subtree from the generated skeleton.
The same corrections are available as typed helpers:
<section {...markAsSkull("Hero", { isTransparent: true })}>...</section>
<fieldset {...tweakForSkull({ hideSubTree: true })}>...</fieldset>
markAsSkull registers the component and applies tweaks to the top-level element. tweakForSkull applies tweaks to a child of an element that is already registered. Neither changes production styling: the tweaks only change what ends up in the generated skeleton.
How it compares
| SkullMaster | Boneyard JS | Shimmer From Structure | |
|---|---|---|---|
| Runtime overhead | No | No | Yes |
| Customizability | Some | Limited | Limited |
| Auto-sync | No | Yes* | Yes |
| Mock fixtures | Not needed | Required | Required |
| Real skeleton markup | No | Yes | Yes |
* Boneyard JS and Shimmer From Structure can regenerate when UI code changes. SkullMaster uses component hashing to alert the developer, but regeneration remains developer-triggered.
The tradeoffs are real:
- Runtime overhead. Shimmer From Structure generates the skeleton at runtime, so there is a runtime generation cost. SkullMaster and Boneyard do not.
- Customizability. SkullMaster exposes per-element control through data attributes. The other approaches are more limited.
- Auto-sync. Boneyard and Shimmer From Structure can regenerate when the UI changes. SkullMaster tells you when a component hash changes, but you trigger the regeneration.
- Mock fixtures. Modals, authenticated content, and other conditional UI require a headless browser and mock fixtures in Boneyard and Shimmer From Structure. SkullMaster captures the component from the real rendered page, so it does not need them.
- Real skeleton markup. Boneyard and Shimmer From Structure produce real skeleton markup. SkullMaster does not: it neutralizes the real markup instead.
That last point is the clearest tradeoff. If you need true skeleton markup or automatic sync, the other tools may fit better. If you want no runtime overhead, no fixture setup, and direct control over individual elements, the capture approach is a good fit.