Live data from Hacker News

Lit: a library for building fast, lightweight web components

lit.dev

141–150 of 180 posts

Re: Lit: a library for building fast, lightweight web components

#141
post #41

I had lit in a project at work and not having to deal with it anymore is just great. We already have another heavier component framework to do the actual application stuff anyway, so having two just because somebody wanted to optimize their resume was such a drag. It all looked nice in theory, but one thing shadow DOM makes worse is A11y, because element ids are now scoped and all the missing describe-by, label-for f…

Integrating these web components into our React codebase has been pretty awful--more of a web components thing than a Lit thing, IMO. We have "scoped styles", except for certain important things like font sizes, so tons of little regressions everywhere when we swap in the web component in place of the old React one. DX-wise, we lost a lot, too. I assume the tooling will get better, or that we'll figure it out more, but it's mostly been a drag

Re: Lit: a library for building fast, lightweight web components

#142
You can also use Web Components directly and manipulate them like regular HTML elements, no need to add a framework. Even using Shadow DOM isn't required.

Typescript can even add Intellisense to "customElements.get" by augmenting CustomElementRegistry: https://gist.github.com/cecilemuller/72fbb3bc3a77d82c8a969cd...

Re: Lit: a library for building fast, lightweight web components

#143

Lit maintainer here. I should be going to bed, but I'll answer any questions if people have any! Not sure why Lit showed up on the front page tonight :)

Lots of comments in here are about shadow DOM, so let me give my take in one place: Yes, Lit uses shadow DOM by default (for good reasons, I think!) and yes you can turn it off component-by-component, but that does bring some challenges. Shadow DOM is most fundamentally just a private branch of the DOM tree for a component's internal DOM details. Frameworks have this implicitly with DOM defined in a component's templ…

We used to put a link to the overall stylesheet in the webcomponents. That works pretty good

Re: Lit: a library for building fast, lightweight web components

#144
post #41

I had lit in a project at work and not having to deal with it anymore is just great. We already have another heavier component framework to do the actual application stuff anyway, so having two just because somebody wanted to optimize their resume was such a drag. It all looked nice in theory, but one thing shadow DOM makes worse is A11y, because element ids are now scoped and all the missing describe-by, label-for f…

Integrating these web components into our React codebase has been pretty awful--more of a web components thing than a Lit thing, IMO. We have "scoped styles", except for certain important things like font sizes, so tons of little regressions everywhere when we swap in the web component in place of the old React one. DX-wise, we lost a lot, too. I assume the tooling will get better, or that we'll figure it out more, b…

Are you migrating from react to something else? I see the appeal of web components as a middle ground for base library when different frameworks coexist (temporarily or not), but everyone is so hellbent on monoculture this days that I don't see the point really.

Re: Lit: a library for building fast, lightweight web components

#146
post #47

Working with a large Vue 3 project and wanting to share some of our components as re-usable web components for other sites to embed... What would be the benefit of rebuilding these components in Lit over using Vue to build them? https://vuejs.org/guide/extras/web-components#building-custo...

>Working with a large Vue 3 project and wanting to share some of our components as re-usable web components for other sites to embed...

Make a fat bundle with a web component or even a mount() function exported and run whatever fits your devx inside, with the API surface as narrow as possible. As long as it's self contained and the size is reasonable, nobody on a consumer side cares how you cook, so optimize your own pipelines to build, test and publish it.

People will build adapters to fit it into their stuff anyway and will let you know.

Re: Lit: a library for building fast, lightweight web components

#147
post #88
post #79

Earlier quoted context omitted.

Web components are 14 years old, and still have the most basic issues and problems that even a 6-month-year-old framework would ashamed to have.

I await your in depth critique on the front page.

There have been many that have hit the front page over the years. If you're not aware of a technology's shortcomings then you're a bad proponent of said technology. They're also almost the antithesis of what the HTMX crowd also preaches as "the one true way" and meanwhile, Wordpressers will continue developing the majority of the world's websites blissfully unaware that either technology even exists.

https://dev.to/ryansolid/web-components-are-not-the-future-4...

https://dev.to/richharris/why-i-don-t-use-web-components-2ci...

https://daverupert.com/2023/07/why-not-webcomponents/

https://paularmstrong.dev/blog/2023/03/11/why-we-do-not-writ...

https://nolanlawson.com/2024/09/28/web-components-are-okay/

https://www.zachleat.com/web/good-bad-web-components/

https://mayank.co/blog/web-components-considered-harmful/

https://adamsilver.io/blog/the-problem-with-web-components/

https://web-highlights.com/blog/are-web-components-dead/

along with some criticisms from very knowledgeable people:

https://x.com/youyuxi/status/1839833110164504691 (author of Vue) https://x.com/Rich_Harris/status/1839785839036887361 (author of Svelte)

Web Components solve a few problems and introduce a few others, use them when they make sense for your needs.

Re: Lit: a library for building fast, lightweight web components

#148
post #4

Great project but I can't stand syntax such as decorators.

They are optional for what it’s worth. They are also landing in standard JS soon.

I wouldn't hold my breath. Decorators landing in standard JS "soon" has been the claim for about a decade running.

Re: Lit: a library for building fast, lightweight web components

#149

Lit maintainer here. I should be going to bed, but I'll answer any questions if people have any! Not sure why Lit showed up on the front page tonight :)

Lots of comments in here are about shadow DOM, so let me give my take in one place: Yes, Lit uses shadow DOM by default (for good reasons, I think!) and yes you can turn it off component-by-component, but that does bring some challenges. Shadow DOM is most fundamentally just a private branch of the DOM tree for a component's internal DOM details. Frameworks have this implicitly with DOM defined in a component's templ…

Aren’t a lot of components leaf nodes, with no slots? Does the shadow dom have any benefits for them?

Re: Lit: a library for building fast, lightweight web components

#150
post #120

Earlier quoted context omitted.

Good luck with your better framework, but if this is the biggest flaw… then there’s really not much to complain about.

Thanks! That's hardly the biggest difference to Lit. I think Lit is a fantastic framework, and I'm not trying to replace it or anything. However, it's really unopinionated which is fantastic for flexibility, but it leads to every deployment looking and feeling very different. Basically, I'm just curious what a full-stack web component framework with strong defaults could look like. This is primarily a learning exerci…

Have you seen https://brisa.build/? Its not web-components first but it looks really well designed and may give you some inspo
Post reply on HN