DEV Community

loading...

Discussion on: Why I don't use web components

Collapse
richharris profile image
Rich Harris Author

Thank you — yep, there are definitely cases where they shine. It's interesting that you had those issues with shadow DOM — in the early days, shadow DOM was kind of the whole point of web components, but I've seen a lot of people back out for similar reasons. Now we see long-running debates about where and whether to use shadow DOM, and whether a given thing belongs in shadow DOM or light DOM. Feels like that distinction has created a lot of extra complexity.

Collapse
oenonono profile image
Junk

Shadow DOM is my favorite part, despite its problems. Custom Elements are just interface for me. I get so much use out content distribution. It's the most important part other than style scoping.

Collapse
webreflection profile image
Andrea Giammarchi

Shadow DOM is controversial because it plays bad with SSR, and its polyfill is not really specs compliant.

To style Custom Elements you also don't need anything different than you do already, and surely you don't need Shadow DOM at all to have Custom Elements.

Maybe Shadow DOM was sold as the true Web Components must do magic, but since 2014 I've never used it, and never needed it.

We ship Custom Elements to dozen million users, and we never used once attachShadow.

TL;DR the debate about Shadow DOM is pretty simple: don't use Shadow DOM if you target legacy browsers without native Custom Elements V1 support, or use very constrained and simple variants of the spec, like the attachshadow library that works down to IE9.