Web Components are not Framework Components — and That’s Okay
Lea Verou · 2024年10月1日
AI 摘要 AI 生成,可能有误
The author responds to recent criticism of Web Components by framework authors, arguing the controversy stems from conflating two distinct use cases: generalizable elements that extend HTML, where Web Components excel thanks to interoperability, and project-specific reactive templating, where frameworks remain superior due to better authoring ergonomics. While Web Components are still far from being a good compile target for frameworks, they don't need to be—their real value lies in reducing duplicated framework-specific reimplementations of common UI elements. The author concludes that frameworks and Web Components are complementary rather than competing, urging the community to stop pitting them against each other and to keep improving the platform's low-level foundations.
Disclaimer: This post expresses my opinions, which do not necessarily reflect consensus by the whole Web Components community.
A blog post by Ryan Carniato
titled “Web Components Are Not the Future” has recently stirred a lot of controversy.
A few other JS framework authors pitched in, expressing frustration and disillusionment around Web Components.
Some Web Components folkswroterebuttals,
while others repeatedlytried to get to the bottom of the issues,
so they could be addressed in the future.
When you are on the receiving end of such an onslaught,
the initial reaction is to feel threatened and become defensive.
However, these kinds of posts can often end up shaking things up and pushing a technology forwards in the end.
I have some personal experience:
after I published my 2020 post titled “The failed promise of Web Components” which also made the rounds at the time,
I was approached by a bunch of folks (Justin Fagnani, Gray Norton, Kevin Schaaf) about teaming up to fix the issues I described.
The result of these brainstorming sessions was the Web Components CG which now has a life of its own
and has become a vibrant Web Components community that has helped move several specs of strategic importance forwards.
继续阅读全文
为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。
AI 摘要Nudeps is a lightweight build tool that lets developers keep using npm install and import dependencies by bare specifiers (like "vue") directly in the browser, without a bundler. It works by copying dependency files from node_modules into a deployable client_modules directory and generating an import map (using JSPM under the hood), touching only dependencies and never the developer's own code, so it requires no watcher and complements any other tooling. It supports many edge cases like dynamic imports, git dependencies, and CJS packages via a require() shim, but doesn't transform code (TypeScript/JSX still need their own tools), is npm-only for now, and may load many-small-module packages more slowly since it doesn't bundle.
AI 摘要In her candidate statement for the 2026 W3C TAG election, Lea Verou announces she is running to return to the TAG after serving two terms (2021–2025), with her participation this time fully funded by Google, Microsoft, and the OpenJS Foundation. She highlights her broad web platform experience and past TAG contributions, including the Web Platform Design Principles, API design reviews, and the Web Platform Gaps initiative. Her central platform is for the TAG to proactively shape the Web's architecture rather than just review it, including treating the rise of AI agents that write and consume web code as an architecture question guided by principles and evidence.
AI 摘要The article argues that the dominant ways of adding icons to web UIs—inline SVG markup and icon fonts—are clunky, boilerplate-heavy, or riddled with problems like large downloads and accessibility issues. The author proposes a pure CSS system where icons are design tokens defined as custom properties (e.g., --icon-trash) and rendered via pseudo-elements using CSS masks, so icons automatically follow text color, can be assigned per-component (e.g., a .delete button gets a trash icon by default), and can reactively change based on selectors, states, or media queries without touching markup. This approach keeps simple cases easy, complex overrides possible, and avoids usability cliffs, with the only remaining need for inline SVG being cases that require dynamically morphing the SVG itself.
AI 摘要In this follow-up to her earlier article, the author argues that the best dark mode toggle is no toggle at all, though if one is required, a two-state control alternating between system and the opposite theme beats a tri-state (system/light/dark) one. She rebuts Bramus's objections—such as the OS auto-switching edge case—contending that the failure scenario is rare and cheaply recoverable, that polls of developers measure preference rather than usability, and that tri-state controls add unnecessary cognitive load by exposing the implementation model instead of the user's actual goal. The piece also recounts the widespread positive reception of the original article and the alternative designs the ensuing debate inspired.
AI 摘要The article argues that tri-state dark mode toggles (Light/Dark/System) leak the underlying data model into the UI and solve a largely imaginary user goal, since real users only seek out the toggle when something looks wrong. It advocates a well-designed two-state toggle that shows the currently resolved value and alternates between storing an explicit override and reverting to the system default, capable of expressing all three underlying states. Key implementation rules include only evaluating the stored override at user interaction, keeping it even if the OS preference later coincides with it, since any resulting confusion is rare and fixable with a single click.