Refactor: Extract pre-hydration web component styles from head.html into a dedicated CSS file
Description
There is a TODO in templates/site/head.html indicating that pre-hydration web component styles (e.g., for ol-read-more and ol-chip) should be moved from an inline <style> block into a dedicated CSS file.
Currently, these styles are embedded directly in the template, which makes the file harder to maintain and prevents effective browser caching.
This change would improve maintainability and separation of concerns by moving these styles into a standalone stylesheet.
Proposed Solution
- Extract the inline CSS from
head.html - Move it into a dedicated CSS file (e.g., in the static CSS directory)
- Link the stylesheet in
head.html - Ensure styles still load correctly before hydration
Benefits
- Cleaner and more readable template files
- Better separation of concerns (HTML vs CSS)
- Improved caching and performance
Hey, I’m a first-time contributor and would like to work on this. I’ll start working on the fix and share a PR soon.
Im also intrested and i wish to work on this
Hi @lokesh,
I worked on this refactor as well and have submitted a PR (#12211).
If you think I should make any changes or follow other conventions, just let me know. Also, we can even collaborate if you like.
Thanks!
Hey @Arnav-0206 , I'm going to close this as we aren't ready to tackle this issue. We need to do a bit more thinking about how we want to address the layout shift caused by web components pre-hydration. It might entail SSR, automated css extraction, or a solution like the one proposed, but we need to do a bit more research on all options first.