Automating the Annoying: Lessons from Extracting Loaders Directly from the DOM

RenderCon Kenya 2026 — ALX The Piano, Westlands, Nairobi — Oct 2026

Watch the recording on YouTube · Read the written version

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:

  1. The source should be the only thing you maintain. Skeletons should be generated from the source, not maintained separately.
  2. 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.
  3. 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.
  4. 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:

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.

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:

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.

Links

Reach out

               . .
    . .       . . .
 . . . .       . .     .
. . . .       . . .   . . .               ,
 . . . .     . . .     . .       _       d#D
. . . . .   . . . . ._. . .    _(%)_      `
   .     . . . . . _(#)_ .    (%%O%%)     "Bzzzz"
        . . . . _ (##O##) .   _ (%)   _
       . . .  _(#)_ (#)  . _ (%)_:  _(%)_
      . . . .(##O##)._\  _(#)%O%%):(%%O%%)
         . .   (#)  _  \(##O##))  |,'(%)
              `. ._(#)_ \,(#)  `. ;  _
                 (##O##) `.      Y _(#)_
                  .(#)\ . .).   / (##O##)
                 . . . `-.(. . ;  ,'(#)
                  . . . . .\. .| (
                 . . . d888888888888b
                  . . ,88888888888888b
                   . .d888888888888888
                    . d888888888888888
                     .`88888888888888P
                       Y8888888888888
                        Y8888888888P
_________________________`Y8888888P____________