I'm not happy with any of the solutions to prevent a flash of undefined components. Has anyone given up on web components for that reason? Or is there a best practice for this?
Sounds like you might like the idea coined as "HTML Web Components": https://blog.jim-nielsen.com/2023/html-web-components/ You basically write all the normal HTML and CSS so it's loaded in right away. But then you also make use of the advantages that defining a custom element gives you.
Shoelace: A library of web components
41–50 of 114 posts
Re: Shoelace: A library of web components
#42Earlier quoted context omitted.
Whatever it requires to hide the menu, that a 3 years old browser doesn’t have, can’t possibly be essential for just a documentation page.
It’s an 8 year old phone … iPhone 6s was released September 2015…
Re: Shoelace: A library of web components
#43I'm not happy with any of the solutions to prevent a flash of undefined components. Has anyone given up on web components for that reason? Or is there a best practice for this?
Sounds like you might like the idea coined as "HTML Web Components": https://blog.jim-nielsen.com/2023/html-web-components/ You basically write all the normal HTML and CSS so it's loaded in right away. But then you also make use of the advantages that defining a custom element gives you.
Re: Shoelace: A library of web components
#44Earlier quoted context omitted.
Not just that, but it basically makes the library incompatible with serverside rendering a la Next.js. We actually explored using Shoelace for a project but ended up having to choose something else instead because of this.
What did you end up using?
Re: Shoelace: A library of web components
#45I'm not happy with any of the solutions to prevent a flash of undefined components. Has anyone given up on web components for that reason? Or is there a best practice for this?
Do webcomponents not have build time pre-rendering or SSR?
Specifically, Shoelace uses Shadow DOM and adoptedStyleSheets.
For Shadow DOM, there’s Declarative Shadow DOM, a way of serialising a Shadow DOM, which is extra work to support, but possible; it’s currently supported in Chromium and Safari, and last month Firefox landed an experimental implementation.
But the key feature and problem of Shadow DOM (in my opinion, more problem than feature) is how it isolates styles. You need to add the stylesheet to every shadow root, via a or element (and hope the browser is clever enough to deduplicate, which it should be in the latter case but I don’t think it will be in the former), or via adoptedStyleSheets, which is generally more efficient and allows shared mutation after construction (unlike the other approaches). Shoelace uses adoptedStyleSheets. Trouble is, that doesn’t work with Declarative Shadow DOM.
Re: Shoelace: A library of web components
#46have been following the development of this very closely for this library, and love the fact that we can script load individual web component in html as bare bones.
Re: Shoelace: A library of web components
#471) Uses slots for composition
2) Does not use CSS-in-JS
3) Lightweight
I understand that slots imply shadow Dom, and then shadow Dom usually means adding/adopting stylesheets into components, and that means css in js.
But there's also ::part that allows piercing the shadow dom. Is there any library that uses it?
Re: Shoelace: A library of web components
#48Re: Shoelace: A library of web components
#49have been following the development of this very closely for this library, and love the fact that we can script load individual web component in html as bare bones.
Can you please elaborate on what this means ?