Building and Sharing Custom Elements using Declarative Shadow DOM

A look at Web Components and templating approaches using Declarative Shadow DOM

Jonas Duri
6 min readAug 23, 2023
A sneak peek into Declarative Shadow DOM

Web components have seen a surge in adoption, changing the way we think about building and sharing reusable UI elements. In smaller organizations, you may find one or two teams that commit to using React, Svelte, or Vue.js for their rendering technology and build a library of shared components. But in large organizations, you most likely won’t have that luxury. This is where the web components standard thrives, offering a component model that can be used in any frontend stack. While building and sharing these components across various teams align well with standard patterns for developing, publishing, and integrating JavaScript components, they come with inherent challenges. Given their primary role as client-side solutions, developers often grapple with issues such as FOUC (Flash of Unstyled Content) or unexpected layout shifts during the initial page render.

Battling FOUC and Layout Shifts

When using custom elements, FOUC and layout shifts are significant concerns. These issues can harm your website’s core web vitals, potentially leading to reduced search ranking visibility. To counteract these effects, you can employ CSS features…

--

--

Jonas Duri

Platform Architect working on frontend & UI solutions for distributed e-commerce systems | https://jduri.com/