LandTS: A Minimalist 177-Line TypeScript Frontend Without Virtual DOM OverheadArticle · digest for October 16
Minimalist sculptural installation of geometric blocks symbolizing the compactness of the LandTS library
Article3 sections≈ 4 min

LandTS: A Minimalist 177-Line TypeScript Frontend Without Virtual DOM Overhead

Step back from the tech hype for a second and look at modern frontend development from the outside. Just to render a form with three inputs and a button, the average project pulls in megabytes of dependencies: React or Vue, a JSX/TSX compiler, a heavy bundler with complex transform plugins, state managers, and strict memoization rules (useMemo, useCallback).

Chasing abstractions, we forgot that the browser itself is an insanely fast runtime capable of manipulating DOM nodes directly. As we discussed in Rendering large lists on the web: CSS content-visibility vs. DOM virtualization, the overhead of intermediate virtual trees often becomes the main bottleneck in client apps.

A developer going by pain64 asked a simple engineering question: can we build a clean component model without a Virtual DOM, compilers, or heavy runtimes? The result is LandTS—a tiny pure-TypeScript library whose core takes up exactly 177 lines of code.

The Three Pillars of LandTS: Components, Zones, and Styles

LandTS solves the three core frontend problems with remarkable brevity:

  1. Creating components with l: No JSX syntactic sugar. The function l(tag, init) creates a standard DOM node and passes it into an init lambda. To nest one element inside another, pass the parent node as the first argument: l(parent, tag, init).
  2. Zone rendering with lz: Instead of diffing huge Virtual DOM trees or wiring complex signal graphs, LandTS introduces "land zones." A zone wraps a markup block that depends on dynamic state. Calling zone.rerender() clears and rebuilds only that specific zone rather than the whole app.
  3. Scoped styles via the css tagged template: You write styles right next to the component and attach them to an element with .applyTo(element).

Async Components Out of the Box

If a component makes a network request, just make the init lambda async—LandTS automatically shows a placeholder until the data arrives:

// Async initialization with data fetching
const userProfile = l('section', async (root) => {
  const res = await fetch('/api/user/me');
  const user = await res.json();
  
  l(root, 'h2', (title) => {
    title.innerText = `Hello, ${user.name}!`;
  });
});

Practical Example: An Interactive Counter

Here is what a full counter component looks like in LandTS with an isolated render zone and inline styles:

import { css, l, lz } from './land.ts';

const counterApp = l('div', (root) => {
  let count = 0;

  // Attach styles directly to the root node
  css`
    padding: 24px;
    max-width: 320px;
    font-family: system-ui, sans-serif;
    border: 1px solid #dcdcdc;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  `.applyTo(root);

  // Define a reactive zone for the value block
  lz(root, (zone) => {
    l(zone, 'h3', (h) => {
      h.innerText = `Current count: ${count}`;
      h.style.color = count > 5 ? '#e11d48' : '#1e293b';
    });

    l(zone, 'button', (btn) => {
      btn.innerText = 'Increment by 1';
      btn.style.padding = '8px 16px';
      btn.style.cursor = 'pointer';
      
      btn.onclick = () => {
        count += 1;
        // Trigger a targeted rerender of this zone only
        zone.rerender();
      };
    });
  });
});

document.body.appendChild(counterApp);

Whenever an element's init function returns a Promise (an async component), LandTS automatically renders a temporary placeholder until the network call resolves, making remote data handling seamless.

Where LandTS Shines

Of course, you shouldn't rewrite massive enterprise portals in 177 lines of code—the library doesn't ship a prebuilt catalog of complex UI widgets. But for lightweight browser extensions, embedded feedback widgets, micro-frontends, and admin tools where every kilobyte counts, LandTS is a breath of fresh air.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 2