TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Web components are okay

278 pointsby keybits8 months ago

31 comments

jeswin8 months ago
I tried to understand the referenced article &quot;Web Components Are Not the Future&quot; - but found that there weren&#x27;t many convincing arguments.<p>The current state of Front-end frameworks is an absolute mess. Speaking for myself, I don&#x27;t want to learn a complex framework. I don&#x27;t want to learn magic that I don&#x27;t understand without reading the documentation (useState, createSignal et al). Magic in frameworks is often a hack, unlike magic in libraries. The first library I used was Prototype. It felt like magic, and it truly was. And so was jQuery, and Backbone. I never had to guess what &quot;useState&quot; does behind the scenes.<p>There are many things which don&#x27;t carry over into Web Components from current JS frameworks. But if you start from Web Components (ignoring everything you know about frameworks), it suddenly becomes intuitive. And it brings in abilities which are missing otherwise, such as isolation via Shadow DOM. It grows on you.<p>In my view the only thing we should retain from the React era is JSX (for many reasons, true type-safety, autocomplete etc). I wrote a library last week for using Web Components with JSX. No magic other than JSX. <a href="https:&#x2F;&#x2F;webjsx.org" rel="nofollow">https:&#x2F;&#x2F;webjsx.org</a>
评论 #41687755 未加载
评论 #41687735 未加载
评论 #41687813 未加载
评论 #41688163 未加载
评论 #41698804 未加载
评论 #41687740 未加载
评论 #41690092 未加载
评论 #41688889 未加载
评论 #41692103 未加载
评论 #41687677 未加载
评论 #41688115 未加载
评论 #41697192 未加载
评论 #41688207 未加载
评论 #41697278 未加载
评论 #41687652 未加载
评论 #41688396 未加载
评论 #41688015 未加载
评论 #41687558 未加载
评论 #41687698 未加载
评论 #41695359 未加载
评论 #41699405 未加载
评论 #41696253 未加载
评论 #41688794 未加载
apitman8 months ago
I think part of the reason people talk past each other on this issue is because they&#x27;re optimizing for different things. If you&#x27;re working for a VC-backed startup with a central product that needs to move quickly and is going to require constant maintenance anyway, a framework might be a good fit for you.<p>But I work in an academic lab. We don&#x27;t have tons of money to maintain the apps that we&#x27;ve written. We need them to just keep working once funding has moved on to new projects.<p>We&#x27;re just finishing up a rewrite of an app from Vue to Web Components. It had dependency rotted to the point where we couldn&#x27;t update anything because of dependency hell. Rather than spend hours trying to fix it, which we&#x27;ve done before and would have to do again until the end of time, I decided to experiment with Web Components. The experience was immediately so nice that we went all in. No regrets. We went from ~15 dependencies to ~1 (d3js).<p>If you&#x27;re curious to try the apps, old one[0] new one[1].<p>[0]: <a href="https:&#x2F;&#x2F;bam.iobio.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bam.iobio.io&#x2F;</a><p>[1]: <a href="https:&#x2F;&#x2F;bam2.iobio.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bam2.iobio.io&#x2F;</a>
评论 #41687910 未加载
评论 #41687768 未加载
评论 #41691703 未加载
评论 #41696696 未加载
mentalgear8 months ago
One of the things I really appreciate about Svelte is its support for generating Web Components through the Custom Elements API. Since Svelte compiles down to plain JS&#x2F;HTML&#x2F;CSS, creating reusable components that work across any framework or vanilla JS becomes seamless. <a href="https:&#x2F;&#x2F;svelte.dev&#x2F;docs&#x2F;custom-elements-api" rel="nofollow">https:&#x2F;&#x2F;svelte.dev&#x2F;docs&#x2F;custom-elements-api</a>
评论 #41693359 未加载
评论 #41697508 未加载
MrThoughtful8 months ago
I have been following the web components discussion for years now and just don&#x27;t see what I can do with them that makes my life as a fullstack developer better.<p>All the examples I have seen use them to template some data into html. I can do that with handlebars already.<p>Am I missing someting?
评论 #41687986 未加载
评论 #41687588 未加载
评论 #41687596 未加载
评论 #41687411 未加载
评论 #41687496 未加载
评论 #41687533 未加载
评论 #41695450 未加载
评论 #41687370 未加载
评论 #41687317 未加载
lapcat8 months ago
The worst part about web components and the shadow DOM is how they can prevent browser extensions from working correctly, or working at all.<p>And the browser vendors aren&#x27;t in a hurry to remedy this situation.
评论 #41692640 未加载
claytongulick8 months ago
I think one of the biggest &quot;mistakes&quot; with web components was coupling them in people&#x27;s mind with shadow dom.<p>For app dev (not library dev) web components are a super lightweight easy option when you stick with the light dom.<p>You can continue to use bootstrap or tailwind or whatever css thing you like, but get great functional encapsulation with near zero cost, especially if you use lit-html or something similar as a renderer.<p>My teams have generally found working with native web components refreshing. It takes a dev coming from the framework world about a week to adjust, and then they never want to go back.<p>Just using simple class properties and a manual call to a render function on set() gives you all the benefits of reactivity without all the hassle of frameworks.<p>The problem most people have with getting started with WCs is that there&#x27;s not much out there showing how do to it in &quot;easy mode&quot;.<p>Most of the getting started things throw you right into shadow dom, css parts, and all these really painful technologies that were primarily intended for use by library authors, not app devs.<p>I&#x27;ve been building apps with native WCs for a long time now, I should get off my keister and write a guide on how to make your life easier with WCs, something like &quot;The Good Parts&quot;.
评论 #41688158 未加载
评论 #41690960 未加载
评论 #41690310 未加载
评论 #41687538 未加载
webdevladder8 months ago
I think this minimizes the fact that interop - the main selling point to me as a user - comes at a performance cost where every component you use could have its own unnecessary runtime attached.[1] Using a framework like Lit with web components is the recommended way to use them.<p>This cost will compound over time where new frameworks emerge, and components get stuck on older versions of their frameworks.<p>I can&#x27;t see this as anything but significant, and not to be minimized. Having multiple redundant libraries on a page is not the direction I would advise anyone to take, particularly not when baked into the accepted best practices. This bodes poorly in the long term.<p>I&#x27;ve listened to the arguments from web component advocates in blog posts, social media, and videos for years now, and I should be in the target market. But on top of the interop tax, they&#x27;re full of negatives that aren&#x27;t present in the mainstream frameworks.<p>Interop works great within each framework&#x27;s ecosystem. The same dynamics that cause developers to seek interop cause them to huddle around a small number of mainstream frameworks. So we get a few vibrant ecosystems that push the state of the art together. Web components cannot keep up on the tech side of things, and introduce a ton of complexity to the web platform - ignorable to me as a dev, but not for browser implementers - in service of their early 2010s designs.<p>[1] <a href="https:&#x2F;&#x2F;x.com&#x2F;Rich_Harris&#x2F;status&#x2F;1840116730716119356" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;Rich_Harris&#x2F;status&#x2F;1840116730716119356</a>
评论 #41688117 未加载
评论 #41687270 未加载
评论 #41688466 未加载
评论 #41687372 未加载
burcs8 months ago
I love web components and am bullish on them breaking us out of the current frontend hellscape we have created for ourselves. I was recently able to give a short talk on the future of frontend, and it seemed like a lot of other people are hopeful for a way out as well.<p>As far as performance we built out a data table for our DB GUI that can load in hundreds of thousands of rows and the scrolling through is still buttery smooth.<p>We actually are getting ready to release our web component library, it&#x27;s a bit early and rough around the edges but would love to get some more eyes on it! www.astra-ui.com
评论 #41687022 未加载
评论 #41687871 未加载
评论 #41687332 未加载
评论 #41687213 未加载
评论 #41696804 未加载
impostervt8 months ago
A few months ago I started a job where I inherited a JS code base that is around 250,000 lines. It was one big class, with several sub classes, that did everything. Some files were 30k lines long.<p>No frameworks, no reactivity. If you click a button, you had to update everything on the screen with event listeners manually.<p>Took the guy years to write it. It&#x27;s like a monk got locked in a cell for years with a basic book of javascript.<p>I started by refactoring into web components, because I had to do it piecemeal. It&#x27;s been a big help, and I&#x27;ve cut 50k lines of code so far. But the real point was to just learn everything the old code was doing before I start a rewrite.
评论 #41695354 未加载
veggieroll8 months ago
One thing about web components that I&#x27;ve appreciated is that they can work without JS enabled (at least in theory). I&#x27;ve done this a few times for progressive enhancement.<p>Broadly I agree with Nolan, though. Web components have enough rough edges that they&#x27;re not going to take over the world in the current state. But, they are pretty nice for certain use cases.<p>I&#x27;m not sure what he means by not playing well with server side rendering though. I&#x27;ve been doing that without issues.
评论 #41687649 未加载
评论 #41687791 未加载
评论 #41688054 未加载
superkuh8 months ago
Web components are okay as long as you only use them to progressively wrap actual HTML elements. If you&#x27;re using custom-elements by themselves like a JS frontend replacement and just making entire web pages full of blank grey boxes that do nothing without JS, you&#x27;re doing a bad job.<p>See: <a href="https:&#x2F;&#x2F;blog.jim-nielsen.com&#x2F;2023&#x2F;html-web-components&#x2F;" rel="nofollow">https:&#x2F;&#x2F;blog.jim-nielsen.com&#x2F;2023&#x2F;html-web-components&#x2F;</a>
评论 #41687400 未加载
mmcnl8 months ago
I don&#x27;t really get this &quot;frameworks vs. web components&quot; discussion. They are both tools to solve different problems. Frameworks exist to render your view as function of state in a declarative way. They use web primitives to define the view layer. Web components can help there, but it doesn&#x27;t solve the state management issue that frameworks aim to solve. That&#x27;s a different problem that requires different solutions. In my opinion they can perfectly co-exist.
mrfinn8 months ago
How can it be possible that we are in 2024 a no one seems to be proposing the most obvious improvement to the web, which is to create a new standard designed for web applications and let the HTML alone serving it&#x27;s original purpose, which was to serve documents? (H*T*ML the T goes for &quot;TEXT&quot;!). Instead of that, and make things complex and unmanageable to the extreme, to &quot;improve&quot; things now we dropped out completely the MVC philosophy and went completely ahead with an spaghetti mess of Javascript, HTML, CSS, and create-your-desired-tags-at-will everywhere, aka Components.<p>PS. And not even mentioning Madnesscript which deserves another chapter in this story of horror.
评论 #41702425 未加载
评论 #41696256 未加载
gaganyaan8 months ago
I really dislike the Shadow DOM part of Web Components. Someone didn&#x27;t learn any lessons from past mistakes and went and reinvented iframes. Trying to write tests or any automation for a web page that uses shadow dom is an exercise in misery, unnecessary at that.
addicted8 months ago
Web components are lacking some basic functionality that makes using them in something complex difficult.<p>For example, one of the deal breakers we faced was the inability to unload and reload a web component. Once you load a web component you’re stuck with it until you refresh the browser.<p>You cannot have an SPA with one page loading 1 version of the web component and another loading another version without some ugly namespace mangling.
drawkbox8 months ago
I dig WebComponents because I love building on standards which promote interoperability across frameworks and have long term lifelines. Standards reduce platform + dev lock-in and reduce framework balkanization and frankly chaos in many cases. You are a better developer if you understand the root standards and core systems, which WebComponents get you closer to.<p>I also like the Lit Framework (<a href="https:&#x2F;&#x2F;lit.dev&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lit.dev&#x2F;</a>) from Google which is rarely mentioned but it is quite nice for some of the simplifications and extras you might need when building them but it doesn&#x27;t get in the way or try to take over your entire domain with dev-lockin.<p>Whether going direct to WebComponents or a higher level simplification like Lit, they really are a freedom from dev lock-in that is nice to see.
skrebbel8 months ago
I&#x27;m bullish on web components as a distribution mechanism. In fact, we&#x27;re currently hard at work betting our entire company (<a href="https:&#x2F;&#x2F;talkjs.com" rel="nofollow">https:&#x2F;&#x2F;talkjs.com</a> - a component library + API for chat) on it.<p>I agree with Nolan here that the performance is <i>fine</i>. People keep comparing web components to React or Solid components, but the latter inherently have a tiny granularity whereas web components is primarily a way to <i>distribute</i> reuseable elements, not an application framework on its own. Don&#x27;t make every tiny piece of your app its own little web component (or, at least, don&#x27;t do it without a framework such as Lit to skip the pain). But web components are <i>the</i> way to build a component once and have it usable in all web frameworks (including none at all) out of the box. That&#x27;s fantastic! And also unprecedented (on the web, that is).<p>It bothers me that so much of the discussion is still about whether web components are good primitives to build frameworks on top of. No, not really, they&#x27;re pretty awful for that! But for distribution, nothing else comes close.<p>I&#x27;d love it for some alternative standard to emerge, without all the awful design choices of web components. And I agree with Rich (Svelte) and Ryan (Solid) that WCs being built into browsers are getting in the way of some other collective component interop design emerging. But until the framework authors stick their heads together and invent a fast, modular, non-shitty, property-only, functional-smelling standard for distributing components, I&#x27;m sticking with web components. For component authors, the only alternative is making a React version, a Preact version, a Lit version, a Svelte version, a Vue version, an Angular version, a Solid version and a vanilla JS version of the same UI component. That&#x27;s awful! Web components are clunky but they&#x27;re here, now!
评论 #41687378 未加载
tannhaeuser8 months ago
Let me explain the argument to you:<p>&gt; <i>You can always add another layer of abstraction to solve a problem but removing one can be difficult.</i><p>The argument being that there&#x27;s no need to add anything to the browser stack and make it even more complex when it doesn&#x27;t add any essential capability. There&#x27;s already JS making everything possible; and yet, they keep on piling stuff. When with custom elements specifically, you also require JS anyway (to declare them).<p>&gt; <i>Elements are not components.</i><p>Idk maybe for &quot;web devs&quot; the concept is difficult to grasp that HTML isn&#x27;t for them. It&#x27;s for text authors, and as such a markup vocabulary where low-level elements are placed next to complex custom controls nilly-willy isn&#x27;t really a useful evolutionary direction.
tomrod8 months ago
I like seeing accessibility respected. Good post.
thomassmith658 months ago
I use web components, but I often want to design classes as MVC. It isn&#x27;t obvious how this should work (though I assume the Web Component spec authors discussed the topic at some point). The awkwardness is:<p>(a) When you instantiate your View class (ie: &#x27;web component&#x27;) from JS, you probably want your Model and View to be &#x27;owned&#x27; by properties of the Controller (eg: con.model and con.view). However...<p>(b) when an HTML tag instantiates your View, the View has to create its Model and Controller. And now there&#x27;s no obvious place to store a reference to the Controller.<p>As a result, you have either to stick the Controller in a global variable somewhere, or - more likely - end up, not just with &#x27;con.model&#x27; and &#x27;con.view&#x27;, but also with a new property: &#x27;view.con&#x27;<p>So... two paths to create everything (Controller-based, or View-based), and this ugly &#x27;.con&#x27; property stuck in the View.<p>But, aside from this gripe, Web Components are okay.
评论 #41688224 未加载
PaulHoule8 months ago
I did a project that used Shadow DOM and related tech to address the problem of embedding a widget into a partner’s web site without any risk of CSS interference. Worked great, but this was one medium-sized widget that did not interact with the rest of the page.
shortrounddev28 months ago
I wish web components had a bit more to them<p>1. I wish you could reliably parse their attributes in the constructor instead of connectedCallback, so that they play better with typescript readonly properties<p>2. I wish I could declare properties in the class and have them automatically map to an attribute<p>3. I wish I could construct them using html instead of manipulating domnodes manylually<p>4. I wish I could construct child nodes first so that I can compose webcomponents with other webcomponents<p>As it stands webcomponents provide the ability to construct a single element at a somewhat predictable moment in time, automatically. That&#x27;s cool, but their interface is lackluster to me
dandrew58 months ago
Web Components are fun. I&#x27;ve played around with Lit, which some people have mentioned. Anybody tried Stencil? It looks similar from the outside but wondering how it plays out mid&#x2F;late-term.
评论 #41691360 未加载
newhotelowner8 months ago
Safari is the only browser without the full support<p>*Supports &quot;Autonomous custom elements&quot; but not &quot;Customized built-in elements&quot;
评论 #41687748 未加载
carlual8 months ago
I found a practical way to foster critical thinking skills and encourage independent thought at the end of Netflix&#x27;s documentary, The Social Dilemma:<p>&gt; I follow people on Twitter that I disagree with because I want to be exposed to different points of view.<p>Here is another good opportunity for it.
wellpast8 months ago
What’s missing in his point and examples about “performance isn’t everything” (aria properties, forEach, …) is that these are cases where you could optimize later when and if needed. Using forEach is a fluid coding choice at the time but if for any reason you need to optimize to a for loop you can with minimal fanfare. But buying into web components is more of a one-way door and harder to iterate optimizations, and that’s the problem.
jongjong8 months ago
Tech discussions are hard to have nowadays because people are highly biased in favor of their current tech stacks.<p>The religiousness which used to be restricted to programming languages has expanded to include frameworks, databases, test runners, infrastructure, CI tooling, libraries; literally everything is a religion nowadays.<p>It makes almost all technical arguments disingenuous and pointless. Like people arguing about whose religion is more correct. Observable facts don&#x27;t matter so much.<p>People see arguments in favor of some alternative stacks as a personal attack against their career.<p>It&#x27;s probably because companies themselves have become so focused on hiring based on these stacks. They have become a matter of livelihood.<p>In the old days, many companies saw software engineering ability as a separate skill; now they barely even use the word &#x27;software engineering.&#x27;
评论 #41692506 未加载
renegat0x08 months ago
This might be a stupid hot take, but I am surprised that so little of web UI exist outside of the browser. I mean why bootstrap or other frameworks are not managed by browser ecosystem? Why millions of people how to download same frameworks over and over?
评论 #41687915 未加载
wordofx8 months ago
&gt; From my own personal experience: at Salesforce<p>lol
breck8 months ago
We do web components better than the web. We just call them Parsers.<p>Geniuses build for The Scroll first. Retards build Web first.<p>(Don&#x27;t misinterpret, I love The Web, but The Scroll is on track to be 100x better)
auggierose8 months ago
Web components are not OK. They are shit. I wouldn&#x27;t touch them, just as I wouldn&#x27;t touch shit.<p>If you find React hooks hard to understand, then I really don&#x27;t need to hear your opinion about anything, including about how web components and HTMX are so great. Just learn programming.
评论 #41695092 未加载
评论 #41695236 未加载
评论 #41695257 未加载
评论 #41695376 未加载