HN 日本語サマリー

← 一覧へ戻る
プログラミング

Elena、プログレッシブWebコンポーネント構築のためのライブラリ

Elena, a library for building Progressive Web Components (elenajs.com)

68 pointsby brianzelip7 コメント

要約

Elenaは、プログレッシブWebコンポーネントを構築するためのシンプルで軽量なライブラリです。HTMLとCSSを先にロードし、その後JavaScriptでインタラクティビティを段階的に追加するアプローチを採用しており、アクセシビリティ、サーバーサイドレンダリング、レイアウトシフトなどの一般的な課題を解決することを目指しています。このライブラリは、フレームワークに依存せず、標準技術に基づいているため、様々なプロジェクトやチームに適しています。

全文翻訳

Components

Introduction

What is Elena? ​

Elenaは、Progressive Web Componentsを構築するためのシンプルで軽量なライブラリです。 多くのWebコンポーネントライブラリとは異なり、ElenaはすべてをJavaScriptに依存させることはありません。HTMLとCSSを先にロードし、その後JavaScriptを使用してインタラクティビティを段階的に追加できます。[1]

Here is a minimal example ​

HTML

Styles

JavaScript

html

<elena-stack direction="row">
  <div>First</div>
  <div>Second</div>
  <div>Third</div>
</elena-stack>

css

@scope (elena-stack) {
  :scope {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-flow: column wrap;
    flex-direction: column;
    gap: 0.5rem;
  }
  :scope[direction="row"] {
    flex-direction: row;
  }
}

js

import { Elena } from "@elenajs/core";

export default class Stack extends Elena(HTMLElement) {
  static tagName = "elena-stack";
  static props = ["direction"];

  direction = "column";
}

Stack.define();

Try it in the playground

Prerequisites

This documentation assumes familiarity with HTML, CSS, and JavaScript. If you're new to custom elements, the MDN guide is a good starting point, though prior experience is not required.

Why was Elena created ​

Elena was created by @arielle after nearly a decade of building enterprise-scale design systems with web components. The recurring pain points were often similar: accessibility issues, server-side rendering, layout shifts, flash of invisible content, React Server Components, too much reliance on client side JavaScript, and compatibility with e.g. third party analytics tools.

Elena was built to solve these problems while staying grounded in web standards and what the platform natively provides. This is how “Progressive Web Components” were born.

Why should I use Elena ​

Elena is built for teams creating component libraries and design systems. If you need web components that work across multiple frameworks (such as React, Next.js, Vue, Angular), render HTML and CSS before JavaScript loads, and sidestep common issues like accessibility problems, SSR limitations, and layout shifts, Elena is built for exactly that.

It handles the cross-framework complexity (prop/attribute syncing, event delegation, framework compatibility) so you can focus on building components rather than plumbing.

Elena’s features ​

🔋

Extremely lightweight

2.9kB minified & compressed, simple and tiny by design.

📈

Progressively enhanced

Renders HTML & CSS first, then hydrates with JavaScript.

🫶

Accessible by default

Semantic HTML foundation with no Shadow DOM barriers.

🌍

Standards based

Built entirely on native custom elements & web standards.

⚡

Reactive updates

Prop and state changes trigger efficient, batched re-renders.

🎨

Scoped styles

Simple & clean CSS encapsulation without complex workarounds.

🖥️

SSR friendly

Works out of the box, with optional server-side utilities if needed.

🧩

Zero dependencies

No runtime dependencies, runs entirely on the web platform.

🔓

Zero lock-in

Works with every major framework, or no framework at all.

Browser support ​

As a baseline, Elena’s progressive approach supports any web browser that’s capable of rendering Custom Elements. After that, it’s up to you to determine what is appropriate for your project when authoring CSS styles and JavaScript interactivity. Elena, the JavaScript library, is tested in the latest two versions of the following browsers:

[画像: Chrome][画像: Safari][画像: Edge][画像: Firefox][画像: Opera]

Next steps ​


  1. Elena supports multiple component models: Composite Components that wrap and enhance the HTML composed inside them; Primitive Components that are self-contained and render their own HTML; And Declarative Components that are a hybrid of these and utilize Declarative Shadow DOM. ↩︎