Search code examples
htmlcssshopify

Repeated CSS files while rendering same section multiple times


What's the best way to include CSS to sections so that they are rendered once no matter how may times the section is called on page in shopify dawn theme.

{{ 'lookbook.css' | asset_url | stylesheet_tag }}

I am calling this section 4 times on page and CSS files also gets called with it. In Dawn theme every section and snippet has its own CSS so I also created a separate CSS file in order to maintain it and more readable. But now I am concerned about the page speed and performance because CSS files is being duplicated 4 times. Is there any other way to do so.


Solution

  • why you don't add to the main css file instead and in that way will render one time, also you can add an if condtion with the URLs only render this css file.