Lit: A 5KB Web Component Library That Skips Virtual DOM Diffing
A component built on Lit works in React, Vue, or plain HTML without an adapter, because it is a native custom element. That interoperability, plus a 5 KB core and precise DOM updates, makes it a credible alternative for teams that want framework-agnostic UI without surrendering developer experience.
Lit sits as a thin layer on top of the browser's native Web Components spec, promising the productivity of a framework without the bundle size. Its core is about 5 KB after minification and it handles reactive state, declarative templates through lit-html, and scoped styles via Shadow DOM. The library's standout technical decision is to bypass the virtual DOM altogether: using JavaScript tagged template literals, it parses each template once and marks the exact positions of dynamic expressions, then updates only those specific DOM nodes when state changes. That cuts out the overhead of building and diffing a shadow tree against the real DOM.
The standards-based foundation means a Lit component is a real custom element, inheriting from HTMLElement, and runs in any HTML context. That makes it a practical choice for shared component libraries and design systems that need to work across React, Vue, or no framework at all. LitElement, the base class, removes the boilerplate of manually syncing properties and attributes, providing reactive properties, declarative templates, and scoped styles out of the box.
The comparison to VDOM frameworks is deliberate. React and Vue maintain an in-memory copy of the DOM and compute diffs on every state change; Lit instead treats updates as surgical operations on the specific dynamic parts. The article argues this gives Lit an edge in update performance and memory usage, and it positions Lit as a more platform-aligned development model.
The claim that Lit's precise updates usually beat VDOM diffing in performance and memory is a generalisation; the actual advantage depends on the size and frequency of state changes, and VDOM frameworks like React batch updates for large trees.
Building on Web Components means Lit gives up some conveniences of framework ecosystems, such as React's state management or Vue's reactivity system, which may be a trade-off for teams already invested in those tools.
Lit's 'future-ready' promise rests on browser standards being slower to change than framework abstractions; if a new DOM API arrives, standard components get it automatically, but frameworks often require migration.
Lit's approach is spot on - rather than inventing a new framework, it stands directly on the Web Components standard, which makes cross-framework component reuse click into place immediately. At 5KB and only touching the changed parts, the lightweight angle is quite appealing.