The situation: you have a dark mode switch that saves the user's preference in local storage. I use the mwc-switch component, but I imagine this would be relevant to other switch components.
The symptom: when the page is loaded with the preference set to dark, the switch starts in its light mode position and slides to the dark mode position.
When my top bar was a web component, I didn't have this problem, and I didn't fully understand why that made the difference until I thought about it: when the switch is embedded in a render template with its attribute set declaratively, it renders correctly the first time, but still doesn't have to wait for DOMContentLoaded. I lost that when I moved the switch outside of a web component and into the top-level DOM.