Web Components as a Business Decision

web-components javascript
Web Components as a pragmatic UI choice for small teams

Most framework decisions are really hiring decisions, maintenance decisions, and migration risk decisions wearing a technical costume. Web Components are worth understanding not because they're "pure" or "native" -- but because they solve specific business problems that framework-heavy stacks create.

The business case

When you pick React, Vue, or Svelte for a project, you're also picking:

Web Components don't eliminate these concerns, but they change the math. They're a browser standard. They don't ship breaking versions. They work alongside any framework or no framework. And they add zero runtime overhead because the browser already knows how to run them.

What Web Components actually are

Three browser APIs working together:

  1. Custom Elements -- define new HTML tags with your own behavior.
  2. Shadow DOM -- encapsulate styles and markup so components don't leak CSS into (or absorb CSS from) the rest of the page.
  3. HTML Templates -- define reusable markup structures.

A minimal example

class StatusBadge extends HTMLElement {
          constructor() {
            super();
            const shadow = this.attachShadow({mode: 'open'});
            shadow.innerHTML = `
              <style>
                span { padding: 2px 8px; border-radius: 4px; font-size: 0.85em; }
                :host([status="active"]) span { background: #e6f4ea; color: #1e7e34; }
                :host([status="inactive"]) span { background: #fce8e6; color: #c62828; }
              </style>
              <span><slot></slot></span>
            `;
          }
        }
        
        customElements.define('status-badge', StatusBadge);
        

Usage:

<status-badge status="active">Live</status-badge>
        <status-badge status="inactive">Offline</status-badge>
        

No build step. No imports. No package.json entry. It just works in every modern browser.

When Web Components make sense

Web Components are a strong fit when:

When they don't

Be honest about the tradeoffs:

Getting started

  1. Create a class that extends HTMLElement.
  2. Attach a Shadow DOM in the constructor for style encapsulation.
  3. Register it with customElements.define('your-tag', YourClass).
  4. Use it in HTML like any other element.

No build step, no CLI, no starter template. That's not a flex -- it's a genuine reduction in startup cost and ongoing maintenance burden.

The bottom line

Web Components aren't a religion. They're a tool with specific strengths: zero runtime cost, no framework lock-in, excellent browser support, and a standard that won't ship breaking changes. For content sites, internal tools, and design systems that need to last, those properties translate directly into lower cost and lower risk. For complex applications with heavy state management, a framework is probably the right call.

Pick the tool that fits the problem. Ship the thing.

Recommended

Web Components + HTMX: A Lean Architecture for Content Sites That Ship @jameslcowanjun 10 '26 web-components, javascript
Fixing Navigation and Analytics: When Your Data Lies About User Behavior @jameslcowanjun 5 '26 htmx, javascript
Mobile-First Layout That Ships: How PrimaryLayout Solves Real UX Problems @jameslcowanjun 6 '26 htmx, css
How This Site Works: Architecture for a One-Person Team @jameslcowanjun 8 '26 htmx, javascript
Less JavaScript, More Leverage: Why I Ship With a 35KB Budget @jameslcowanjun 22 '26 javascript, performance
OpenClaw: What It Is and How to Get the Most Out of It @jameslcowanjun 5 '26 openclaw, javascript
HAL: Cutting 100-300KB of JavaScript by Moving Routing to Build Time @jameslcowanjun 10 '26 htmx, javascript
Documentation That Scales: Constitution, Contracts, and Runbooks @jameslcowanjun 8 '26 documentation, markdown
HAL: Build-Time Link Rewriting That Makes Navigation Feel Instant @jameslcowanjun 18 '26 htmx, javascript
Why I Built My Own Analytics Pipeline (And What It Actually Costs) @jameslcowanjun 18 '26 analytics, javascript
The Static Site Playbook: Shipping a Content Product on a Near-Zero Budget @jameslcowanjun 11 '26 static-site-generation, javascript
Progressive Enhancement with HTMX: Ship Fast, Degrade Gracefully @jameslcowanjun 8 '26 htmx, javascript
Anthropic Trained Its Replacement @jameslcowanjun 9 '26 anthropic, ai
Karpathy Was Wrong: OpenClaw Still Outruns Its 5 Real Alternatives @jameslcowanjun 11 '26 openclaw, ai
Pydantic: The Open Source Layer Quietly Running the AI Economy @jameslcowanjun 22 '26 pydantic, python
The YC S26 Deadline Just Closed. Here's What Separates the 1.5% From Everyone Else. @jameslcowanjun 17 '26 startups, yc
OpenClaw 2026.2.23: The Agent Browser Upgrade @jameslcowanjun 19 '26 openclaw, ai
Why I Skipped the CMS @jameslcowanjun 10 '26 markdown, static-site-generation
Zero-Server Analytics: How I Replaced a SaaS Bill with Netlify Functions and GitHub @jameslcowanjun 8 '26 netlify, analytics
Static Site Generation: The Business Case for Pre-Rendered HTML @jameslcowanjun 14 '26 static-site-generation, performance

Recommended

Web Components + HTMX: A Lean Architecture for Content Sites That Ship @jameslcowanjun 10 '26 web-components, javascript
Fixing Navigation and Analytics: When Your Data Lies About User Behavior @jameslcowanjun 5 '26 htmx, javascript
Mobile-First Layout That Ships: How PrimaryLayout Solves Real UX Problems @jameslcowanjun 6 '26 htmx, css
How This Site Works: Architecture for a One-Person Team @jameslcowanjun 8 '26 htmx, javascript
Less JavaScript, More Leverage: Why I Ship With a 35KB Budget @jameslcowanjun 22 '26 javascript, performance
OpenClaw: What It Is and How to Get the Most Out of It @jameslcowanjun 5 '26 openclaw, javascript
HAL: Cutting 100-300KB of JavaScript by Moving Routing to Build Time @jameslcowanjun 10 '26 htmx, javascript
Documentation That Scales: Constitution, Contracts, and Runbooks @jameslcowanjun 8 '26 documentation, markdown
HAL: Build-Time Link Rewriting That Makes Navigation Feel Instant @jameslcowanjun 18 '26 htmx, javascript
Why I Built My Own Analytics Pipeline (And What It Actually Costs) @jameslcowanjun 18 '26 analytics, javascript
The Static Site Playbook: Shipping a Content Product on a Near-Zero Budget @jameslcowanjun 11 '26 static-site-generation, javascript
Progressive Enhancement with HTMX: Ship Fast, Degrade Gracefully @jameslcowanjun 8 '26 htmx, javascript
Anthropic Trained Its Replacement @jameslcowanjun 9 '26 anthropic, ai
Karpathy Was Wrong: OpenClaw Still Outruns Its 5 Real Alternatives @jameslcowanjun 11 '26 openclaw, ai
Pydantic: The Open Source Layer Quietly Running the AI Economy @jameslcowanjun 22 '26 pydantic, python
The YC S26 Deadline Just Closed. Here's What Separates the 1.5% From Everyone Else. @jameslcowanjun 17 '26 startups, yc
OpenClaw 2026.2.23: The Agent Browser Upgrade @jameslcowanjun 19 '26 openclaw, ai
Why I Skipped the CMS @jameslcowanjun 10 '26 markdown, static-site-generation
Zero-Server Analytics: How I Replaced a SaaS Bill with Netlify Functions and GitHub @jameslcowanjun 8 '26 netlify, analytics
Static Site Generation: The Business Case for Pre-Rendered HTML @jameslcowanjun 14 '26 static-site-generation, performance