✓ Email copied to clipboard
← BACK TO JOURNAL

The React Hangover: Why We Ditched the Virtual DOM for Creative Artifacts

ADVERTISEMENT Google AdSense
The React Hangover: Why We Ditched the Virtual DOM for Creative Artifacts

There is a specific kind of pain that sets in when your `requestAnimationFrame` loop starts stuttering, but your `console.log` says everything is fine. The code is clean. The state is managed. The virtual diffing is efficient. And yet, the user’s cursor trails behind the mouse pointer by exactly two frames. It’s not a bug. It’s the architecture talking.

The Abstraction Tax

For the last decade, the industry consensus has been clear: build everything with React. Or Vue. Or Svelte. The reasoning is sound for 80% of the web. You need state management. You need reconciliation. You need components to update when data changes. But creative artifacts—3D scenes, generative typography, complex canvas interactions—don’t care about data changes. They care about time. They care about the delta between the previous frame and the current one.

When we started our work on the 'Kinetic Type' series for a major client, we hit a wall. We were rendering 500 individual text nodes, each driven by a custom spring physics engine. In React, every tick of that physics engine triggered a state update. Every state update triggered a re-render calculation. Even if the DOM didn’t change, the JavaScript engine was busy reconciling the virtual tree. We were paying an abstraction tax on every single frame.

"React is a fantastic tool for managing complex state flows in forms and lists. Use it for a particle system, and you are fighting the tool."

— Studio whiteboard scribble, March 2024

The standard advice is to throttle updates. To memoize components. To use `useRef` to bypass state. We tried all of it. It felt like duct-taping a cracked engine block. The problem wasn’t the code inside the component; it was the mechanism that told the browser to check the component in the first place.

Going Raw

We made a radical call: strip out the framework for the interactive artifacts entirely. We kept React for the app shell—the navigation, the content sections, the static copy. But for the creative sandboxes? We went native. Web Components. Custom Elements. Shadow DOM. No build step for the artifact logic. No transpilation for the hot path.

It felt archaic. It felt dangerous. Writing imperative JavaScript in 2024 smells like 2012. But when we profiled the new implementation, the difference was night and day. The CPU usage dropped by 40% during idle states. More importantly, the input latency vanished. The cursor moved, the physics engine reacted, and the GPU received the command in the same frame. No diffing. No reconciliation. Just direct command to the browser.

The Hybrid Architecture

This is where the nuance lies, and where most developers get it wrong. We didn’t throw away React. We fenced it out of the high-performance zones.

Our architecture now looks like this:

  1. The App Shell: Pure React. Handles routing, data fetching, and static layout. It doesn’t care about 60fps; it cares about correctness and accessibility.
  2. The Artifact Bridges: Custom Web Components (`<creative-canvas>`, `<kinetic-text>`). These are registered globally. They expose a simple imperative API via `connectedCallback` and `disconnectedCallback`.
  3. The Communication Layer: We don’t pass props down for high-frequency data. Instead, the React parent passes a reference to a data store or a callback function once. The Web Component then takes over. It listens to its own internal state. It drives its own loop.

Consider the setup for a WebGL scene. In a traditional React Three Fiber approach, you are fighting the render loop. You are trying to sync React state with Three.js state. It’s a constant negotiation. In our Web Component approach, the `<gl-scene>` element is a black box. The React app says, "Here is the initial camera position and the asset URL," and then the Web Component handles the entire lifecycle of the WebGL context, the resize observers, and the animation loop. The React tree never wakes up again unless the user changes the scene entirely.

// The bridge is simple, brutal, and effective
class CreativeCanvas extends HTMLElement {
  connectedCallback() {
    this.setupWebGL();
    this.startLoop();
  }

  disconnectedCallback() {
    // Critical: Clean up GPU resources to prevent memory leaks
    this.destroyGLContext();
    this.stopLoop();
  }
}

customElements.define('creative-canvas', CreativeCanvas);

Handling State Without State

The hardest part wasn’t the rendering. It was the data. How does the Web Component know when the user changes a color in the React UI? We abandoned prop-drilling for this. Instead, we used a lightweight, framework-agnostic event bus. Or, in some cases, we just mutated a shared object reference. It’s ugly. It’s not "pure" in the functional programming sense. But it’s fast.

When a user drags a slider in the React control panel, we update a value in a shared config object. The Web Component’s animation loop reads that value every frame. No event listeners. No state updates. No re-renders. Just a memory read. It’s as cheap as it gets.

The Trade-offs Are Real

I’m not here to tell you that React is dead. It isn’t. For standard web apps, it’s still the best tool in the toolbox. But for creative engineering, where performance is the product, the overhead is fatal.

There are downsides. We lost hot module reloading for the artifacts during development. We have to write our own lifecycle management. We have to be more careful with memory leaks, because if a Web Component fails to clean up its event listeners, it doesn’t just crash the page; it silently bloats memory until the tab becomes unusable. We spent three days chasing a leak in a resize observer that React would have caught during unmount. The ecosystem is thinner. You can’t just `npm install` a pre-built, optimized 3D interaction kit. You build it.

But the result is a site that feels physical. The interactions aren’t simulated; they are direct. The user’s intent maps directly to the GPU command. There is no intermediary layer adding milliseconds of latency, no virtual diffing causing jank, no framework deciding when your code is allowed to run.

If you are building a dashboard, stick with React. But if you are building a thing that dances, breathes, or reacts to touch with the precision of a mechanical watch, stop fighting the framework. Turn it off. Go native. Let the browser do what it does best: render pixels, fast.

ADVERTISEMENT Google AdSense
// DISCUSSION TERMINAL

READER ESSAY DISCUSSIONS (0)

Share your architectural perspectives, technical notes, or critique.

LEAVE A THOUGHT Markdown & clean text supported
💬

No discussions recorded yet.

Be the first to spark the dialogue on this essay.

← PREVIOUS ESSAY

Stop Bouncing: Why Kinetic Type Fails Until It Respects the Fovea