I'm using nextjs for SSR. I'm using this technique to render styles on server side. So when DOM is downloaded it not just gets HTML but also all the CSS it needs to paint in a style tag.
Once the HTML is parsed it starts painting - good so far, the problem starts once JS is downloaded and parsed. Especially _app.js, styled-components deletes existing styles, reference.
How does this affect performance?
My consensus:
- FCP and LCP will be delayed because of the repaint
- With browser busy painting and repainting, main thread is blocked and might be unable to process user interaction, eventually resulting in framerate drop.
Does the same thing happen when route changes because it'll pull new JS files and compile and set styles. Is this the cost we have for styled-components?