Comment

Comment by lelanthran

I've found much use out of custom elements.

On nice use, that took me maybe 30m to code up, is a `<remote-fragment>` element.

    <remote-fragment src=/fragments/topbar.htmlf />
simply retrieves the specified file and adds it to the DOM where the `remote-fragment` is declared.

No need for server-side scripting to include common parts of the HTML page.

There's a bunch of similar use-cases currently satisfied by fat client frameworks or server-side languages that simply go away when you have custom elements.

So, yeah, you can do components with webcomponents they way you do much of react components, but there's some stuff that you can do with webcomponents that just makes life a little bit better[1].

[1] Experimenting with propagating state throughout a (client-side) application using only declarations in HTML, with custom elements performing stuff.

parent lelanthran 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton