With custom elements you can just drop `<my-dropdown>` in your server template and that's where the dropdown widget will be.
Something like Shoelace[1] would be very nice to use with Rails.
All the reasons are here: https://dev.to/stuffbreaker/web-components-and-ssr-2024-edit...
There's nothing very special in sending a html tag and then attaching functionality to it with javascript when it's loaded in the browser.
At least custom elements can just be including in framework-specific templates and be included in the rendered output, even if not deeply server-rendered.
It's actually very difficult to do this correctly and at scale with a framework like React, because in React you need an ID and JS call to initialize each embedded component, when custom elements initialize themselves.
Anyway, you have an axe to grind, so have fun with that. I'll see you next time I make a positive comment about web components I guess.
- all SSRed custom components are framework/library specific and cannot be rendered outside of javascript runtimes
- you need a JS call to initialize each custom component (though this is likely provided by the bundled JS)
- since when providing an id in a server-rendered HTML become an insurmountable challenge?
- and they have many additional issues. Example in the sibling comment: https://news.ycombinator.com/item?id=43641081
> Anyway, you have an axe to grind,
I don't have an axe to grind. I correct the magical wishful thinking that exists around custom components