Chapter 9. Dynamic CSS

Up until now, this book has considered CSS files to be static assets. That is, what is requested from the server and delivered to visitors of your site is exactly the same in every instance. Although this is almost always the expected behavior and most performant way to implement CSS, it is possible to tailor the output of our CSS dependent on other factors and deliver different CSS to different users.

There are several reasons you might like to do this, some for the benefit of developers and some for the benefit of users. From the developer's perspective, it can be useful to use variables[84] or to dynamically populate CSS. For any repetitive code, such as colors or particular blocks of CSS, storing this once and maintaining ...

Get Pro CSS for High Traffic Websites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.