All Projects → oliviertassinari → A Journey Toward Better Style

oliviertassinari / A Journey Toward Better Style

Licence: mit
A Journey toward better style

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to A Journey Toward Better Style

Css In Js Benchmarks
Stars: ✭ 360 (+46.94%)
Mutual labels:  css-in-js, jss, inline-styles
Prejss
Get the power of PostCSS with plugins in your JSS styles. 🎨 Just put CSS into JS and get it as JSS object.
Stars: ✭ 238 (-2.86%)
Mutual labels:  sass, less, jss
Stylelint
A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
Stars: ✭ 9,350 (+3716.33%)
Mutual labels:  sass, less, css-in-js
Vscode Stylelint
A Visual Studio Code extension to lint CSS/SCSS/Less with stylelint
Stars: ✭ 260 (+6.12%)
Mutual labels:  sass, less, css-in-js
Moo Css
模块化面向对象的css写法规范策略。适用于大中小型C端项目样式开发,旨在提高开发和维护效率。
Stars: ✭ 79 (-67.76%)
Mutual labels:  sass, less, css-in-js
Gulp Starter Kit
A simple Gulp 4 Starter Kit for modern web development.
Stars: ✭ 134 (-45.31%)
Mutual labels:  sass, less
Glup
Some of the gulp tutorial -《gulp笔记》
Stars: ✭ 136 (-44.49%)
Mutual labels:  sass, less
Vbuild
"Compile" your VueJS components (sfc/*.vue) to standalone html/js/css ... python only (no need of nodejs). Support python components too !
Stars: ✭ 236 (-3.67%)
Mutual labels:  sass, less
Jsxstyle
Inline style system for React and Preact
Stars: ✭ 1,990 (+712.24%)
Mutual labels:  css-in-js, inline-styles
Styled Jsx Plugin Sass
Plugin to add Sass support to styled-jsx. Warning this is a Proof Of Concept plugin.
Stars: ✭ 115 (-53.06%)
Mutual labels:  sass, css-in-js
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+648.16%)
Mutual labels:  sass, less
Compile Hero
🔰Visual Studio Code Extension For Compiling Language
Stars: ✭ 169 (-31.02%)
Mutual labels:  sass, less
Svg Sprite
SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)
Stars: ✭ 1,648 (+572.65%)
Mutual labels:  sass, less
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+566.53%)
Mutual labels:  sass, less
Kirby Webpack
💪 A Kirby CMS starter-kit with modern frontend tools
Stars: ✭ 150 (-38.78%)
Mutual labels:  sass, less
Rollup Plugin Styles
🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
Stars: ✭ 116 (-52.65%)
Mutual labels:  sass, less
Webpack Encore
A simple but powerful API for processing & compiling assets built around Webpack
Stars: ✭ 1,975 (+706.12%)
Mutual labels:  sass, less
Yarsk
Don't use this, use Create React App
Stars: ✭ 199 (-18.78%)
Mutual labels:  sass, less
Kit
ReactQL starter kit (use the CLI)
Stars: ✭ 232 (-5.31%)
Mutual labels:  sass, less
Style Resources Loader
CSS processor resources loader for webpack
Stars: ✭ 214 (-12.65%)
Mutual labels:  sass, less

A Journey toward better style

Acknowledgment

  • I would like to thank Nathan Marks for the awesome work is has done addressing the styling issues.
  • I would like to thank Pete Hunt for his inspiring talk on reusable components.
  • I would like to thank the following oranizations for giving me the opportunity to share this topic:
  • Paris.js
  • ReactJS-Paris

Date

  • 2016-10-27
  • 2017-01-26

Online version

CSS-in-JS comparison

We started looking for the best styling solution available. Nathan Marks built a custom solution for the needs of Material-UI: stylishly. Ultimately we reverted. We think that it's much better to rely on the community. Still, that was a very valuable experimentation.

Regarding the community, looking at the MicheleBertoli's repository. You can tell that there is a lot a solution available.

What's the best one for our needs?

For the sake of this presentation, I have selected 5 libraries that I think have taken valuable tradeoffs. I'm gonna give my point of view in the rest of this section. The information given are biased by my understanding of the reality.

  • CSS modules

    • Singularity: Extended CSS DSL. Generate style at built time.
    • Motivation: Having some isolated and composable module of CSS. Stay as close as possible to the CSS ecosystem.
  • Aphrodite

    • Singularity: Per rule style usage and injection.
    • Motivation: Khan Academy was looking for a better way to style components with an existing code base. E.g. usage of !important.
  • styled-components

    • Singularity: Uses post-CSS at runtime.
    • Motivation: ? My best guess is, leveraging JS power while still using the CSS syntax.
  • JSS

    • Singularity: Has a low-level API.
    • Motivation: ? I have no clue. I should be asking @nathanmarks.
  • Fela

Interesting dimensions

We can't compare anything without some dimensions. But having too much of them add noise.

⚠️ Be aware that horse transportation is better than cars when following biased dimensions. I have sorted them by importance.

  • The API.
  • Is it taking full advantage of JavaScript? JavaScript is a much more powerful language than CSS. When using it, you no longer have to worry about CSS linter, CSS syntax, CSS pre-processor
  • Is the API low or high level? The theming requirement is quite high for Material-UI. The much freedom we have, the better.
  • Is the API declarative? The more declarative we are, the better.
  • Time to first paint. We have a legacy of poor performance with our inline-style implementation (lack of caching). Reducing the delay between an interaction and something on the screen is quite critical for us. I have run a simple benchmark on a modified version of CSS-in-JS There is quite some factor than can make a difference. I have noticed a factor x2 of difference between the fastest solution (CSS modules) and the slowest one (styled-components).
  • Is the style pre-processed at runtime of build time?
  • Is the style injected as class names used or upfront during the bootstrap?
  • How are the classNames generated? E.g. computing a hash of the rule object could be expensive.
  • Library size. Users of Material-UI could be using a single component out of the available ones. E.g. the <DatePicker />. We want to minimize the entry price of using a single component.
  • Server Rendering. Server side rendering a page drastically improve perceived performance for a user first visit (for repetitive one, Service Worker are even more efficient). Material-UI can't be taken seriously without a strong answer to this point.
  • Can requests be parallelized? I.e, not using a singleton, that's also bad for security.
  • Is the API allowing streaming the response?
  • Unbiased. The less coupled with a solution we are the better. We also want to make sure the solution we are going to use reach a broad audience. E.g. LESS is used by the Angular and React community. That's increasing odds of success.
  • Are we coupled to React?
  • Are we coupled to Webpack?
  • Debug. Users of Material-UI were complaining that the debugging experience was poor with inline-style. Browser dev tool handles much better the CSS. Still, the styling solution can impact it.
  • Are the classNames readable in dev mode?
  • Are the classNames injected into a single style element or multiple?
  • CSS output size. That last dimension is less interesting. I was just curious.

Results

CSS modules Aphrodite styled-components JSS Fela
API -- + o + ++
Time to first paint ++ o - + o
Library size in kB ~0 18 126 22 9
Server Rendering + o - ++ o
Unbiased o o - + +
Debug - o o + -
CSS output size o ++ + + o
  • ++ awesome
  • + great
  • o enough
  • - not great
  • -- no

Going forward

Material-UI has chosen JSS. It's addressing our unique needs. Your needs are most likely different. It could be better for you to use a another solution. Be sure you make an informed choice 💡.

The compared libraries are going to improve. My comparison might not worth anything one year from now.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].