CSS Components logo

Benchmarks

Performance tests and comparisons.

The tests

We've put together a test suite to test a range of performance factors across multiple CSS-in-JS libraries and CSS Components.

All tests use object notation. All tests were run in a production environment, on a machine with the following spec:

Just like CSS Components, our benchmark tests are also open-source.

Initial injection

The timing that it takes apply the initial styles. This happens when a component is rendered.

CSS Components
0.0042ms
Emotion
0.0709ms
Stitches
0.0771ms
styled-components
0.1015ms

Updating variants

Since we are just switching classNames, changing variants is now faster than ever.

CSS Components
0.0047ms
Stitches
0.0148ms
Emotion
0.029ms
styled-components
0.0361ms

Note: Since styled-components and Emotion don't offer a first-class variant API, this was done via prop interpolation.

Updating style or css prop

The style or css is the best way to handle dynamic styles. This needs to happen fast - and it does!

CSS Components
0.0065ms
Stitches
0.015ms
Emotion
0.0666ms
styled-components
0.1333ms

Note: Since css-components don't offer a first-class css prop, we are comparing against the standard style prop.

Mounting deep tree

In this test, we mount a tree with many nested nodes.

CSS Components
1.7666ms
Stitches
2.1333ms
Emotion
3.6333ms
styled-components
4.0193ms

Note: This test was taken from the styled-components benchmarks. Emotion also tests against this.

Mount wide tree

In this test, we mount a tree with many sibling nodes.

CSS Components
3.08ms
Stitches
3.6366ms
styled-components
5.898ms
Emotion
6.036ms

Note: This test was taken from the styled-components benchmarks. Emotion also tests against this.

Summary

Our benchmarks compare against Stitches, styled-components and Emotion because they're the most popular CSS-in-JS libraries, and they've pushed us to improve our performance. Our goal with these benchmarks is to provide transparent performance comparisons for the community.

If you'd like us to include your CSS-in-JS library, or think the tests could be improved, please open an issue.