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.

HTML with Superpowers: An Introduction to Web Components

155 pointsby lysergiaover 2 years ago

21 comments

qwtelover 2 years ago
Just awful. 10 years in the making (if you can call endless bikeshedding committee meetings the &quot;making&quot; of anything) and still barely usable.<p>It offers nothing in way of ensuring that custom elements behave like builtin HTML elements. Half the elements I&#x27;ve come across will break or perform no-ops when you update an attribute or set a propety after it was attached to the DOM. Nevermind detaching and reattaching to the DOM, which will break virtually all of them (including my own sad contributions to this space).<p>The exception to this are those built using a 3rd party library like lit-element or stenciljs, which fill in the obvious omissions of these specs. Perhaps in another 10 years, a mangled version of half of one of them can be standardized? In the meantime, each component shipping its own frontend library or inlining the same core functions over and over again does nothing in the way of interoperability. You can bundle every popular JS framework and mix their components today. The reason you don&#x27;t do it then or now is bloat, not the lack of a minimally viable shared component interface.<p>Besides, if you&#x27;re going to use a 3rd party library and associated bundler&#x2F;compiler, you might as well pick a good one such as React, Vue, Svelete, Solid or even jQuery UI. Using any of these, you can design and build an entire app faster than the bikeshedding commissars from goog and aapl can agree on whether &quot;open&quot; or &quot;closed&quot; should be the default for attaching a shadow DOM (at the risk of ruining the joke: there was no agreement; the developer has to provide a value in each instance...)
评论 #34335225 未加载
评论 #34335205 未加载
评论 #34336175 未加载
评论 #34338022 未加载
评论 #34337656 未加载
评论 #34337661 未加载
评论 #34339829 未加载
评论 #34336100 未加载
lordgroffover 2 years ago
It obviously hasn&#x27;t happened, but I hope that web components eventually make serious inroads. A UI library for React, Vue, Svelte, Solid, whatever... Imagine being able to have a component library that works with any of them (or none of them).<p>Since I really like mithril and there&#x27;s one UI library, I&#x27;ve been playing with Shoelace and Crayons and they&#x27;re pretty nice to work with, but I remain a bit puzzled why there&#x27;s so few players in the space.
评论 #34334139 未加载
评论 #34336686 未加载
评论 #34334608 未加载
评论 #34334092 未加载
评论 #34337268 未加载
评论 #34336782 未加载
apatheticonionover 2 years ago
My biggest gripe with web components is an inability to sandbox them. That forces me to put reusable &quot;components&quot; within iframes for security reasons.<p>That said, generally speaking, web standards really suck at offering sandboxing capabilities for third party integrations.
评论 #34334837 未加载
colecutover 2 years ago
Why is there no standard&#x2F;widely used vanilla-js based webcomponent for creating a table with filtering+sorting+pagination? It&#x27;s such a common and useful thing.
评论 #34337164 未加载
评论 #34335591 未加载
评论 #34334976 未加载
评论 #34334987 未加载
评论 #34338156 未加载
danielvaughnover 2 years ago
One of the problems with native encapsulation is that UI frameworks almost never fully satisfy the product requirements for a given application, so in some cases it’s always necessary to override either behavior or styling. If you remove that capability with a shadow DOM, you damn well better be sure that your abstraction is perfect.
评论 #34336057 未加载
_boffin_over 2 years ago
I’ve been playing with webcomponents for a month or two and really love them. I do wish that IntelliJ would play nice with the formatting of them though.<p>Question: when and or if they gain in adoption, could you see them replacing react? If not, what’s the use-cases that you believe they wouldn’t work for?
评论 #34334254 未加载
评论 #34334145 未加载
rektideover 2 years ago
I really hope some day we can appreciate that webcomponents are the best way to give users agency. Its an ok dev tool, but it takes so much invisible chaotic nonsense that JS does on modern sites &amp; it can make it real, make it represented &amp; visible &amp; malleable on the site. It makes the web co-programmable, alike the better visions of what hypercard &amp;al were maybe heading towards.<p>Treating the web as a low level platform that we can extense on top of, grow &amp; further, with new, creative higher-level layers of hypermedia: that is a path to software with a soul, not just for big companies hacking out features, but genuine good for society. A malleable cohesive comprehendible connected information space.
misterbwongover 2 years ago
Web components have their place but they&#x27;re no panacea and the ecosystem is still pretty young. This is coming from someone that has been leading a decently large StencilJS web component project for over a year now.<p>Documentation and Google-ability of the subject isn&#x27;t great so prepare to some digging and experimentation.<p>The current native feature set is somewhat lacking so you&#x27;re definitely going to want to augment with some sort of helper framework&#x2F;library. Building any significantly sized project purely native with vanillaJS would be challenging.<p>There are also some unique hurdles with this type of project that our org had to work through-mainly on the integration and design side of it.
评论 #34336072 未加载
评论 #34336146 未加载
logankeenanover 2 years ago
I evaluated web components a few months ago. Everything was great except event propagation. Let’s say I have a component which is a DIV that wraps a label and an input. How can a consumer listen to the onchange event of the component which should map to the inputs onchange event. I could never come up with a holistic solution that would work for all components. It’d require a lot manual work mapping the input event to a new event that is triggered on the web component. I’d be interested if anyone found a better pattern
评论 #34335677 未加载
abathurover 2 years ago
I&#x27;m optimistic about Web Components at the design&#x2F;behavior level. It&#x27;s nice to see us inching towards a world where the web stack has the native tools to handle all of the design&#x2F;application responsibilities we&#x27;ve heaped on them at the right level of abstraction.<p>I did have some early hopes that it would also be a good way to enable content authors to coin and style markup within their posts&#x2F;articles&#x2F;etc., but the JS required makes me feel like it&#x27;ll be too heavy for that use-case for most.
fergieover 2 years ago
But I just want to be able to specify a header or a footer in vanilla HTML...
评论 #34337513 未加载
评论 #34337507 未加载
foobarbecueover 2 years ago
Lack of &lt;import&gt; ruins web components. Still need js to go fetch your component if you want it in a separate file. So you end up having to use webpack or whatever. Sigh.
POPOSYSover 2 years ago
This is just an ad for a course - can be removed.
hyperhelloover 2 years ago
I’m curious how often you encounter web designers with enough experience with CSS to make web components worthwhile but not enough “JavaScript know how” not to.
评论 #34334121 未加载
dmitriidover 2 years ago
Everyone (me included) is discussing web components, and no one is discussing the contents of the site itself:<p>- extremely light on content<p>- goes out of its way to <i>not</i> present anything more complex than non-functional pieces of code or static examples<p>- while advertising that they are &quot;easy to use&quot;, the Writing section immediately skips to comparing and using frameworks and libraries<p>- I guess is a front to get the courses at $39&#x2F;month, but the only link is on the front page<p>This is a horrible, bad, no good resource that offers nothing of value.
globalise83over 2 years ago
Have been using Stencil.js extensively in recent months, and after understanding how it works, I find it a viable and indeed preferable alternative to using react. It has functional components, uses JSX, is based on top -&gt; bottom propagation of state etc., but outputs a web component library that can be used without any dependencies except for the JS script tag.
radoover 2 years ago
Still waiting for declarative (JS free) support in all browsers.
metta2uallover 2 years ago
I&#x27;ve found Web Components to be a very nice way of adding interactivity to a server-rendered application (e.g. server-side Blazor). Lit works quite well and has options to avoid an extra build step (<a href="https:&#x2F;&#x2F;lit.dev&#x2F;docs&#x2F;getting-started&#x2F;#use-bundles" rel="nofollow">https:&#x2F;&#x2F;lit.dev&#x2F;docs&#x2F;getting-started&#x2F;#use-bundles</a>)
nathiasover 2 years ago
Web Components are a good concept but the implementation is terrible even as designed. OOP JS is itself terrible, but the end result are files of thousands of lines where vanilla JS + html would require just a few. I&#x27;m currently working with lit, Web Components and TS and it feels like coding C# or Java.
lloydatkinsonover 2 years ago
Web Components were and still are a failure.
WhiteBlueSkiesover 2 years ago
39$ per month? That&#x27;s insane.