πŸ”₯

Lit

Web Components library built on standard APIs with efficient updates

Results Summary

Performance

99%
Lighthouse Score

Bundle Size

15.4KB
Gzipped

Build Time

0.9s
Average

Load Time

1.7s
LCP

Complexity

84
Cyclomatic

Performance Metrics

CLS
0.0550
FCP
1558ms
LCP
1713ms
TBT
1ms

Bundle Analysis

Compression
3.8x
File Count
1
JS %
98.8%
Total Size
58.7KB

Build Info

Build Time
0.9s
Output Size
2.2MB
HMR Time
105ms
Dev Startup
1.0s

About the Lit Weather Front App

Status

  • Lint
  • Build
  • Test

Usage Instructions

First, follow the repo setup instructions.
Then cd into ./apps/lit/ and and use the following commands:

  • Dev Command npm run dev
  • Test Command npm run test
  • Lint Command npm run lint
  • Build Command npm run build
  • Start npm start
For troubleshooting, use npm run verify from the root of the project.

App Requirements

The purpose of this project, was to build the same identical app in every frontend framework, in order to benchmark and compare their performance. As such, each app is built to meet identical requirements, which are then verified with the test suite.

Technical Requirements

  • Binding user input and validation
  • Fetching external data asynchronously
  • Basic state management of components
  • Handling fallback views (loading, errors)
  • Using browser features (location, storage, etc)
  • Logic blocks, for iterative content and conditionals
  • Lifecycle methods (mounting, updating, unmounting)

Feature Requirements

  • 🌦️ Live weather conditions
  • πŸ“… 7-day weather forecast
  • πŸ” City search functionality
  • πŸ“ Geolocation support
  • πŸ’Ύ Persistent location storage
  • πŸ“± Responsive design
  • β™Ώ Accessible interface
  • 🎨 Multi-theme support
  • πŸ§ͺ Fully unit tested
  • 🌐 Internationalized

Lit Implementation

Web Components & Custom Elements

The weather-app.js extends LitElement and registers as <weather-app> using customElements.define(). All components are true Web Components that work in any framework.

Tagged Template Literals

Lit uses JavaScript tagged template literals for both HTML templates (html\`) and CSS styles (css``). This provides syntax highlighting and type safety without build-time compilation.

Reactive Properties

Static properties are defined with static properties = { _isLoading: { state: true } }. Changes to these properties automatically trigger re-renders of only the affected parts.

Shared Style System

The shared-styles.js demonstrates Lit's CSS module system using css tagged template literals for design system consistency across components.

Shadow DOM Encapsulation

Each Lit component renders in its own Shadow DOM, providing true style encapsulation without CSS-in-JS runtime overhead.

About Lit

Real-world App

Since the weather app is very simple, and doesn't show of the full features of a framework, it may be helpful to see a more practical implementation of a Lit app. So, checkout:
Email Comparison Logo

Email Comparison

An objective comparison of privacy-respecting email providers

Intro to Lit

About Lit

Lit is a framework from Google built around Web Components. It’s minimal, modern and uses standard browser APIs rather than reinventing the wheel. Great when you want reusable components without a massive framework overhead. It’s gaining traction for design systems and apps that need native-feeling components.

My thoughts on Lit

Lit can feel like stepping back into the old React class component days, but actually the cohesion to web standards makes Lit pretty... lit. It's built around Web Components, which is both its greatest strength and biggest frustration. Everything is properly encapsulated and framework-agnostic, but the developer experience feels surprisingly verbose for 2025.

The weird expression syntax has caught me out a lot. Want to bind a property? Use .value="${this.temp}". A boolean attribute? ?disabled="${this.loading}". An event listener? @click="${this.handleClick}". It's functional once you memorize the symbols, but it breaks the flow when you're trying to think about business logic.

Class-based components can feel outdated after years of hooks and functional patterns. Creating a simple weather display requires extending LitElement, defining @property decorators, implementing render(), and handling lifecycle methods manually. It works, but feels like unnecessary ceremony.

The shadow DOM isolation is cool in theory - your styles can't leak, global CSS can't interfere. But in practice, it creates more problems than it solves. Want to style components consistently? Good luck getting your design system to work across shadow boundaries. Because of this, I really struggled to get the shared weather styles working across the Lit app. If you want to submit a PR to fix this, please do!

But Lit really does shine for design systems and component libraries where you need true framework-agnostic components. I did build Email Comparison in Lit, but in heindsite, I think that was a mistake!

Choosing a Framework

Stack Match Stack Match

Not sure if Lit is right for your project? Use Stack Match to select your preferences and get a tailored recommendation based on the benchmark data.

Stack Match Screenshot