DEV Community

Discussion on: Web components in 2021: the Good, the Bad and the Ugly

Collapse
 
dam profile image
kj🦝💕

You can avoid FOUC by using a shared css file that is first loaded by the page then linked inside the WC template.

The browser will have already cached the shared styles so it will Not reload the stylesheet, but instead use the cached version. Linking the stylesheet in the template adds the shared styles to the WC's scope.

Collapse
 
emileperron profile image
Émile Perron

There's something to be done with assets preloading to help with the FOUC, indeed.

However, it seems you can still run into FOUC issues when your components make use of the shadow DOM, as the structure of the element will likely change between the initial page load and the moment that the WC is rendered.