I’ve ran into a problem and I need a little help in pointing me in the right direction.
I added a class to the global styles (.search-highlight). I want to use that class dynamically on elements with JS. That means that there is no element on the page initially that have this class. I assume that Bricks doesn’t load a class into the page specific css where there is no instance of an element with that class. But now the highlight function doesn’t work after the search is done and JS is run because there is no loaded .search-highlight class.
How can I forcefully load a class on any or every page?
That’s correct. However, you can add the class either to the page settings » custom CSS, or, to use it across the entire site, to Bricks » Settigs » Custom Code » Custom CSS or Theme Styles » Stylesheet.
Thank you for your answer! Yes I know that but I easily forget that option because it is in a separate environment and not convenient to use. What is in my mind is maybe you can add a flag to any css class that it should be included in the always-loaded styles css file? Just thinking loud
For now I solved it with adding it to the code element that holds the custom JS.
One thing that I do and can be helpful here is to add a empty block with display: none and the the class to that block. This way it get’s added to the page CSS. I use this method when I’m using the class inside a custom code element or any text element with custom html tags.
This can also be used to render classes in a specific order if you are using some kind of utility classes.