Skip to main content
Dublin Library

The Publishing Project

Evaluating web component libraries

 

The modern web development landscape is characterized by a drive towards creating more modular, maintainable, and long-lasting applications. At the heart of this movement lies the Web Components specification, a suite of browser-native technologies designed to address the historical challenges of code reuse and framework lock-in. Understanding this foundation is essential for evaluating the libraries in this report. ## The Philosophy of Web Components Web Components are not a framework, but rather a set of standardized APIs built directly into modern browsers. They are built on three core pillars that enable the creation of truly reusable user interface elements. * **Encapsulation**: The Shadow DOM API is arguably the most powerful feature of Web Components. It provides a way to attach a hidden, separated DOM tree to an element. This "shadow root" encapsulates the component's internal structure and styling, meaning that CSS styles defined within the component do not leak out to affect the main page, and global page styles do not break the component's internal layout. This robust scoping mechanism allows developers to build self-contained components with simple, reliable CSS, free from the complexities of naming conventions like BEM or the need for CSS-in-JS solutions to avoid style collisions. * **Interoperability**: The Custom Elements API allows developers to define their own HTML elements with custom tag names (e.g., ``) and encapsulate their behavior within a JavaScript class. Because these are native browser features, they are inherently framework-agnostic. A component built as a Custom Element can be used in any HTML environment, whether it's a static site, a content management system, or an application built with React, Vue, Angular, or Svelte. * **Reusability & Future-Proofing**: By building on web standards, components become durable assets. Unlike framework-specific components, which are tied to the lifespan and versioning of a particular framework, web components are designed to be future-ready. An organization can invest in building a design system or a library of shared components with the confidence that they will remain usable for many years, even if the underlying application frameworks change. * **Reusability & Future-Proofing**: By building on web standards, components become durable assets. Unlike framework-specific components, which are tied to the lifespan and versioning of a particular framework, web components are designed to be future-ready. An organization can invest in building a design system or a library of shared components with the confidence that they will remain usable for many years, even if the underlying application frameworks change. ## Positioning the Libraries The three libraries under review: `Lit`, `Wired Elements`, and `Shoelace` are not direct competitors but rather represent different layers within the Web Component ecosystem. Their relationship is hierarchical, which is a critical distinction for any technical evaluation. * **Lit as the Foundation**: Lit is not a library of components, but a library for building them. It is officially described as a "simple library for building fast, lightweight web components". It provides a minimal, efficient base class (LitElement) and a declarative templating system (lit-html) that significantly simplify the process of creating custom elements from scratch. Lit is the tool for the component author. * **Shoelace and Wired Elements as Implementations**: Both Shoelace and Wired Elements are collections of pre-built web components that are themselves built using Lit. This means that choosing to use Shoelace or Wired Elements is implicitly an adoption of Lit's core rendering technology and philosophy. They provide ready-to-use UI elements, saving developers from having to build common components like buttons, cards, and inputs themselves. The existence of such diverse and successful libraries built upon Lit is a strong testament to the power and flexibility of the underlying foundation. The fact that a single base library can enable both a professional, enterprise-grade UI kit like Shoelace and a niche, aesthetic-focused tool like Wired Elements demonstrates its maturity and capability. This vibrant ecosystem indicates that Lit is not merely a theoretical tool but a practical and robust choice for a wide spectrum of development needs. ## Lit: The Foundation for Modern Web Components [Lit](https://lit.dev), maintained by Google as the successor to the [Polymer Project](https://polymer-library.polymer-project.org/3.0/docs/devguide/feature-overview), is a lightweight library designed to make it easier to build fast, high-quality web components. It sits directly on top of the Web Components standards, adding a thin layer of developer-friendly features to reduce boilerplate and enhance productivity without sacrificing the performance and interoperability of the native platform. ### Core Concepts and Architecture Lit's architecture is centered around three key features that work together to provide a modern development experience. * **LitElement Base Class**: The cornerstone of Lit is the `LitElement` class. Developers create their own components by extending this class, which is itself a convenient wrapper around the native `HTMLElement`. This base class handles the component's reactive update cycle, abstracting away much of the manual boilerplate required when working with the raw Custom Elements API. * **lit-html Declarative Templates**: Lit uses JavaScript's native tagged template literals for defining a component's HTML structure. A template is created by prefixing a template literal string with the html tag. * This approach has a significant performance advantage over frameworks that use a Virtual DOM (VDOM). Instead of creating a complete virtual representation of the DOM and diffing it against the real DOM on every update, `lit-html` parses the template once, identifies the dynamic parts (e.g., where `{this.name}` is), and creates direct bindings to those specific DOM nodes. On subsequent updates, it only touches the parts of the DOM that have actually changed, resulting in extremely fast and memory-efficient rendering. * **Reactive Properties**: To manage state, Lit provides a reactive properties system. When a class field is declared as a reactive property (using the `@property` decorator in TypeScript or a static properties block in JavaScript), Lit automatically observes it for changes. Whenever the value of a reactive property is modified, the component automatically schedules an update, re-rendering its template with the new state. This declarative model greatly simplifies state management and eliminates the need for manual render calls. ### Strengths: The Case for Building with Lit * **Performance and Size**: Lit's most cited advantage is its exceptional performance and minimal size. Weighing in at only around 5-6 KB (minified and compressed), it adds negligible overhead to an application's bundle size, which is critical for fast initial load times. Its rendering engine, which avoids VDOM diffing in favor of targeted DOM updates, is blazing fast at runtime. * **Interoperability and Low Lock-in**: Since every Lit component is a standard web component, it is fundamentally interoperable. These components can be dropped into any webpage, regardless of the tech stack, from plain HTML to a complex React application. This makes Lit an ideal choice for creating shareable components or entire design systems that need to serve multiple teams using different frameworks. The library's low coupling means there is no centralized scheduler or state manager, making it easy to adopt Lit incrementally or migrate away from it one component at a time if needed. * **Developer Experience**: While more low-level than a full framework, Lit provides what its creators call "just what you need to be happy and productive". It smooths over the rough edges of the native Web Component APIs, handling complexities like attribute-to-property reflection and providing a clean event-handling syntax (`@click=${...}`). This results in a development experience that is far superior to writing vanilla web components while remaining close to the platform. Furthermore, Lit does not require a compiler or a complex toolchain to get started; it can be used directly from a CDN. ### Weaknesses and Strategic Considerations * **Lifecycle Complexity**: Web components adhere to a specific set of lifecycle callbacks (`connectedCallback`, `disconnectedCallback`, `attributeChangedCallback`) that are part of the web standard. While powerful, this lifecycle is more complex to manage than the simpler onMount/onUnmount hooks provided by many JavaScript frameworks. Developers using Lit must still understand and correctly manage this underlying complexity, especially for cleanup tasks like removing event listeners to prevent memory leaks. * **Server-Side Rendering (SSR)**: SSR remains the most significant challenge for the web component ecosystem, and Lit is no exception. Multiple sources acknowledge that SSR is "not a solved problem" in the web components world. The fact that Lit's official SSR package remains in the experimental "Lit Labs" section underscores that it is not yet considered a mature, production-ready feature. This is a critical limitation for any project that relies on SSR for performance or SEO. * **Ecosystem and Tooling**: While Lit itself is stable and well-supported by Google, its surrounding ecosystem of third-party tools, libraries, and ready-made solutions is smaller and less mature than those of established frameworks like React or Vue. While you can start without any tools, a production-grade workflow will likely still involve setting up a bundler, a linter, and a testing framework. A crucial strategic point to understand is that Lit is a library, not a framework. It is intentionally minimal and scoped only to the task of authoring components. It does not provide solutions for application-level concerns such as routing, internationalization, or advanced global state management. While experimental packages like `@lit-labs/context` exist for passing data through a component tree, they are not intended as a replacement for a full-fledged state management library in a complex application. Therefore, a team choosing Lit is not just choosing a component authoring tool; they are also committing to making separate, deliberate architectural decisions for all other aspects of their application. This offers ultimate flexibility but also requires more architectural planning compared to adopting an all-in-one framework. ## Wired Elements: A Niche Aesthetic for Unique Interfaces [Wired Elements](https://wiredjs.com) occupies a unique and specific niche in the component library landscape. It is not designed for mainstream application development but rather to provide a distinct, hand-drawn aesthetic for specialized use cases. ### Core Philosophy and Technology The defining characteristic of Wired Elements is its visual style, which is explicitly designed to look "hand-drawn" and "sketchy". This effect is achieved through the use of the [RoughJS](https://roughjs.com/), a graphics library that draws shapes with a sketchy, imperfect appearance. Under the hood, these sketchy visuals are rendered inside standard web components that are built using Lit as their base. A key feature of this approach is its intentional randomness. Just like two shapes drawn by hand are never identical, "no two renderings [of a Wired Element] will be exactly the same". ### Clarifying a Point of Confusion: Wired Elements vs. Wire Elements Pro It is important to address a potential source of confusion arising from a similarly named but entirely unrelated product. [Wired Elements](https://wiredjs.com): This is the open-source, framework-agnostic web component library that is the subject of this report. Its purpose is to provide a sketchy, hand-drawn UI aesthetic. It is built with Lit and RoughJS. [Wire Elements Pro](https://wire-elements.dev): This is a separate, commercial product that provides a suite of UI components specifically for the Laravel and Livewire (PHP) ecosystem. It has no relation to the sketchy aesthetic or the The components from wiredjs.com include modals, slide-overs, and other elements designed to integrate with a PHP backend. This report will focus exclusively on the former. ### Strengths: The Case for a Sketchy Look * **Unique Aesthetic**: The library's primary strength is its visual identity. It is an excellent choice for projects where a standard, polished corporate look is undesirable. Its most common use cases are for creating wireframes, mockups, and interactive prototypes. * **Focus on Functionality**: The deliberately sketchy style has a practical benefit in the early stages of a project. It can help guide feedback from clients, managers, or beta testers away from cosmetic details and toward the core functionality and user flow of the application. * **Simplicity**: Wired Elements is very easy to use. The library can be installed from npm or loaded directly from a CDN with a single `