DEV Community

Beto Muniz
Beto Muniz

Posted on β€’ Edited on β€’ Originally published at betomuniz.com

4 1 1 1 1

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 on the list.

πŸ”— https://github.com/callstack/linaria

πŸ‘‰ Compiled

A familiar and performant compile time CSS-in-JS library for React created by Atlassian.

πŸ”— https://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.

πŸ”— https://github.com/4Catalyzer/astroturf

πŸ‘‰ style9

CSS-in-JS compiler based on the ideas of Facebook's stylex

πŸ”— https://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.

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more