Against CSS in JS

Avatar of Chris Coyier
Chris Coyier on

Keith J Grant on the connection between HTML and JavaScript:

This coupling is real, and it is unavoidable. We must bind event listeners to elements on the page. We must update elements on the page from our JavaScript. Our code must interact bidirectionally and in real-time with the elements of the DOM.

And so:

… the mantra of React is to stop pretending the DOM and the JavaScript that controls it are separate concerns.

But:

The relationship between CSS and JavaScript is not like the relationship between HTML and JavaScript. With HTML, a true separation of concerns between the markup and the corresponding component code is impossible (because they are in fact the same concern). With CSS, this separation is possible. And, in fact, the concerns are unique, so separation is vital to clean code organization.

Direct Link →