Re: [csswg-drafts] Simply sharing external stylesheets between DOM and Shadow DOMs (#8112)

The "multiple downloads" thing isn't problematic if you use appropriate caching headers - only the first request will actually download, and the rest will fetch from cache.  (You'll want to do this anyway, so repeated visits to your page don't trigger unneeded downloads.)

Additionally, browsers have internal heuristics for avoiding repeated parsing work when given the same stylesheet multiple times, and definitely apply it in cases like this. (If you use an inline `style` element in your shadows, for example, it'll only get parsed the first time, and the result reused for later components. I think they even literally share the stylesheet object with copy-on-write semantics.)

That previous paragraph is heuristic, tho; if you want to *ensure* a single download and parse, yeah, using constructable stylesheets is currently the way to go.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8112#issuecomment-1324386868 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 23 November 2022 00:07:48 UTC