Require JS and CSS for a Sitecore components


According to HTML best practices and guidelines we need to put styles in head (so that they would be applied to html immediately after rendering) and scripts in the end of body (so that they will not block your browser from downloading other content). On the other hand for Sitecore you need to create component, which could require some styles on specific scripts, and put them in a placeholder in the middle of the page.

This results in two common solutions: small scripts and style section spread all over the page, added in each component, or huge styles and scripts files containing all required content and added according to guidelines.

There should be a better way, lets see how it looks.

Continue reading “Require JS and CSS for a Sitecore components”

Require JS and CSS for a Sitecore components