Revolution vs. Evolution: CSS in JS
My concerns with CSS in JS
Mark Dalgleish did a great job highlighting the many upsides of using a CSS in JS approach so I take the chance to express my biggest concern with this methodology.
Many (competing) libraries
Competition is usually not a bad thing but because all of those libraries are using their own approach and most of them are not interoperable, it will not be possible to share bits of styles as NPM packages which just work for all of the available libraries. Frameworks like Bootstrap would have to provide a dozen variants for every major CSS in JS library commonly used.
I’m a big believer in writing reusable, shareable small components and moving away from huge monolithic frameworks like Bootstrap. Most of my open source work (node-sass-magic-importer and avalanche) is focused at working on ideas of how we can solve this problem with the tools we already have or how we can improve the tools we currently have to make this possible. But with the current state of CSS in JS libraries we’re moving further away from achieving this goal — without a solid standard, code sharing will not be feasible in a sustainable way. We already have a solid standard, which is just good old CSS (and Sass as a superset of CSS).
The best solutions come from gradually improving existing systems instead of radically replacing old with new. Hence the success of the familiar SCSS syntax of Sass (over the more radical Sass syntax) or the fast adoption of ES6 compared to more extreme approaches like CoffeeScript or Dart.
Humans evolved from unicellular organisms over a time span of billions of years. Western democracies where improved by taking the best bits and pieces of revolutionary ideas like socialism and, in more recent years, the green movement — whereas many of the states formed by radical revolutions were doomed to fail almost as spectacular as they were created (although there might be situations where a revolution is needed).
CSS in JS is a revolution which is currently going on. If we’re smart, we can learn a lot from it and gradually improve our existing systems to implement the best ideas and solutions provided by popular CSS in JS libraries.
Evolution is boring, democracy is boring and standards (and even more the process of defining and improving them) are very boring. But in the long run those boring and slow processes will win. And it might be that CSS in JS will win, but it will be a very boring and unspectacular version of CSS in JS, defined by some very boring standards and after an even more boring process of defining those standards.