[英]Is there any performance difference between conditional classes, CSS-in-JS, CSS Modules and utility-first CSS?
Is there any difference (specially performance-related) between dynamic/conditional classes (like JedWatson's classnames ) with SCSS, CSS Modules, CSS-in-JS (styled-components, JSS, Emotion, etc) and utility-first CSS (Tailwind)?动态/条件类(如JedWatson 的类名)与 SCSS、CSS 模块、CSS-in-JS(styled-components、JSS、Emotion 等)和实用程序优先 CSS(Tailwind)之间是否有任何区别(特别是与性能相关) ?
I'm kick-starting a new React (probably with Next) project in a few weeks and I'm currently doing my researches to build the front-end tech stack.我将在几周内启动一个新的 React(可能与 Next)项目,目前我正在研究构建前端技术堆栈。 Any help and any opinion are appreciated!任何帮助和任何意见表示赞赏!
Performance is not something I'd focus on when choosing how to write CSS. Most of the time, you probably won't need to worry about the performance of your CSS, though there are a few exceptions:在选择如何编写 CSS 时,我不会关注性能。大多数时候,您可能不需要担心 CSS 的性能,但也有一些例外:
* + *
), then that can impact runtime performance as the DOM grows.如果选择器有可能匹配许多元素(例如,猫头鹰* + *
),那么随着 DOM 的增长,这会影响运行时性能。 This never happens with utility-first CSS, and probably doesn't happen with CSS Modules or CSS-in-JS.这永远不会发生在实用程序优先的 CSS 上,并且可能不会发生在 CSS 模块或 CSS-in-JS 上。Instead of performance, I'd recommend looking at the developer experience for each of the CSS "frameworks" and how it relates to the rest of your tech-stack.除了性能,我建议查看每个 CSS“框架”的开发人员体验,以及它与您的技术堆栈的 rest 的关系。 99 / 100 times (citation needed), your performance bottleneck will not be your CSS. 99 / 100 次(需要引用),你的性能瓶颈不会是你的 CSS。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.