News for hackers. Stuff that matters.
Re:If Web Components are so great, why am I not using them? by herpdyderp on Wednesday August 02, 2023 @07:07PM (#36979109)
I've been using web components now for years and I will do everything I can to never write frontends in anything else. I totally agree with point 2 though: the Polymer phase was very weird, but, as mentioned, https://lit.dev is great and, imo, the perfect abstraction.
Re:If Web Components are so great, why am I not using them? by benatkin on Wednesday August 02, 2023 @07:10PM (#36979145)
Lit seems functionally equivalent to Svelte. Might Lit only be better if you have a preference towards declaring classes? Perhaps tracing back to Backbone or React before hooks?

Svelte supports custom elements: https://svelte.dev/docs/custom-elements-api

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.
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/

Re:If Web Components are so great, why am I not using them? by phpnode on Thursday August 03, 2023 @06:11AM (#36983739)
When did @click and so on become part of HTML?
Re:If Web Components are so great, why am I not using them? by dannye on Friday August 04, 2023 @11:11AM (#37001126)
If Lit is equivalent to Svelte, then BASIC was equivalent to COBOL
Re:If Web Components are so great, why am I not using them? by brianzelip on Wednesday August 02, 2023 @08:05PM (#36979603)
Would love to peruse a couple example repos for learning if you can share some public links.
Re:If Web Components are so great, why am I not using them? by mariusor on Thursday August 03, 2023 @02:48AM (#36982244)
Not parent, but I wrote some components based on lit-js, they're here: https://git.sr.ht/~mariusor/oni/tree/master/item/src/js. The top level call would be oni-main-actor.render()

However I am a total noob so it might not be entirely idiomatic. An example for the end result is at https://releases.bruta.link

Re:If Web Components are so great, why am I not using them? by mock-possum on Thursday August 03, 2023 @01:27AM (#36981748)
Lit is so good. It’s just enough extra on top of native web components - to be useful, but without feeling like it stacks a bunch of extra bullshit. I really wish more teams were into it.
Re:If Web Components are so great, why am I not using them? by rapnie on Thursday August 03, 2023 @06:47AM (#36983968)
It looks good. But it is a Google project, and with Google's DRM attack on the web I don't know if I'm willing to give these more traction by being among the user base.
Re:If Web Components are so great, why am I not using them? by beanjuiceII on Thursday August 03, 2023 @02:07PM (#36989489)
lit looks like someone's trying to make a GUI in java, what is the need/deal with these annotations etc?