-
-
Notifications
You must be signed in to change notification settings - Fork 826
feat(runtime): Remove redundant SSR style elements after adoptedStyleSheets adoption #6576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for raising @Jagget |
|
@johnjenkins not removed stylesheets doesn't have negative impact, they just duplicate one another and basically useless. For every element browser should read and parse the same styles twice:
|
|
But I’m not sure that impacts anything? The initial style tag is already there and parsed as part of the initial page render, then they’re converted to constructible stylesheets. Removing the original style tag doesn’t impact any of that? |
|
@johnjenkins But still, there is twice amount of styles. And we don't need 50% of that, because it's the same. But the browser still have to read it and apply it. I think you can count browser's memory consumption as an impact here. Because browser can unload duplicated styles. |
|
Removing styles frees memory, especially with many shadow DOM instances. Imagine, if a page with 100 shadow DOM components, that's 100 redundant <style> nodes... I mean, yes, it's not a parsing optimization. It's more of a runtime cleanup. |
|
Kk - think that makes sense. Can you try and schedule the removal (eg via |
428a4b8 to
9f07e17
Compare

During hydration, shadow DOM components adopt styles via
adoptedStyleSheets. The SSR-rendered<style sty-id="...">elements inside shadow roots become redundant and can be removed.adoptedStyleSheetsis populated