Post

Last year, Nathan Fowler suggested user defined Web Components, like this: gomakethings.com/user-defined... If collisions are happening a lot for you, that suggests that your naming conventions aren't specific enough. I'd personally address that first.

gomakethings.comUser-defined Web ComponentsOver the weekend, Remy Sharp asked… Are we at all worried, or even wary, of web component name collisions? The concern here is that if you have a custom element named <toggle-tabs>, and then importa...

Why? ¯\_(ツ)_/¯ I’ve started using custom elements (instead of <div> soup), even when no JS is needed. Then I’m adding a <script src> tag when I want to progressively enhance the element with JS. Then in some cases, my templating system adds multiple instances of a custom element to a page.

What I’m doing is akin to shortcodes, but in pure HTML. So instead of checking which elements needs JS loaded for progressive enhancement in my static site build, I’m just adding a <script src defer> tags to the shortcode templates. Then customElements.apply handles any redundancy.

And by "shortcode template" I mean something like a layout partial (an HTML DocumentFragment) that gets included into a layout, server side.

0 reposts0 likes