Re:If Web Components are so great, why am I not using them?
by spankalee on Wednesday August 02, 2023 @08:30PM
(#36979791)
Lit uses standard languages, doesn't require a compiler, is faster, and is smaller as you amortize the library size over a collection of elements. Those are real differences.
[ Parent
| on HN ]
Re:If Web Components are so great, why am I not using them?
by benatkin on Thursday August 03, 2023 @12:54AM
(#36981536)
> uses standard languages, doesn't require a compiler
It recommends a build step, but yes, you can use it without one. Also, TypeScript isn't a standard language. So if you're using .ts you may as well use .svelte.
> is faster
I don't know that Svelte has been benchmarked with custom elements. Either way it's plenty fast.
> is smaller as you amortize the library size over a collection of elements
That's kind of a funny thing to worry about. It has improved in Svelte 4, though. https://svelte.dev/blog/svelte-4 I also don't know that Lit is so small in practice. With Lit you get to use map and the ternary operator and all that jazz, like React. https://lit.dev/docs/templates/conditionals/