Post

Honest question, do web components REQUIRE javascript? Without js, do they just break the page?

0 reposts1 like

Without calling the Custom Elements JavaScript API any <tag-name> (with a hyphen!) becomes a valid HTMLElement (aka UNdefined Custom Element), not HTMLUnknownElement as many blogs and even AI claim. A Declarative ShadowDOM (DSD) with <template shadowrootmode="open"> IS a UNdefined Custom Element

the best thing about web components is that there’s tons of ways to use the specs that combine to make up that term. you can do “custom elements” which are just your own HTML tags that you can style with css with no js involved.

if you want a progressively-enhanced experience then there are two ways to go, the “html web components” approach which uses js to augment the existing html, or shadow dom that upgrades the custom element when js is rendered. you can use declarative shadow dom with no js, or anything in between!