Build Time CSS-in-JS: Explained
𧡠Have you heard about Build Time CSS-in-JS libraries?
π₯ Build Time CSS-in-JS libraries are moving a step forward about use CSS-in-JS in a performance-first manner remaining the ergonomic CSS-in-JS design and processing the CSS in build time instead of leaving it to JS runtime. It aims to remove the current CSS-in-JS negative cost.
β‘οΈ Still, Build Time CSS-in-JS libraries reduce significantly or remove completely the downsides while parsing, generating, and rendering CSS through JS, which impacts directly and positively memory consumption and metrics like Largest Contentful Paint, which also impacts the page load UX and performance.
π ββοΈ There are a few examples and proof of concepts exploring the Build Time CSS-in-JS approach. The most popular proposals that I know are:
π Linaria
The most popular, powerful and active in the list.
π github.com/callstack/linaria
π Compiled
A familiar and performant compile time CSS-in-JS library for React created by Atlassian.
π github.com/atlassian-labs/compiled
π astroturf
A library that lets you write CSS in your JavaScript files without adding any runtime layer, and with your existing CSS processing pipeline.
π github.com/4Catalyzer/astroturf
π style9
CSS-in-JS compiler based on the ideas of Facebook's stylex
π github.com/johanholmerin/style9
π¬ And thatβs it from me - Iβm fascinated by this and still learning. So let me know if you know more libraries like these and/or more about this topic.