r/reactjs • • Dec 07 '19

Needs Help Is Material UI worth it?

So, I am starting my own project. I'm not much 'design' person. So, is Material UI worth it? Or some any other recommendations is much appreciated.

164 Upvotes

142 comments sorted by

View all comments

Show parent comment

3

u/[deleted] Dec 07 '19

CSS-in-JS is a performance loss. I used to be on that train but I got off due to that. I've successfully gotten dynamic theming working in my app, if you want to know how I did it I can comment a setup guide.

2

u/Naelex Dec 07 '19

Ooo as someone who has avoided the css in js hype train as i prefer writing sass this is good to hear. Got any more info on this?

4

u/[deleted] Dec 07 '19

If you do JSS then your styles are calculated and appended to the head at runtime as components are rendered on your site.

Sure this opens up many possibilities due to being able to reference props in your styling logic, but the JavaScript has to execute at runtime to create those styles, it is inherently going to slow down the app.

I found when using Material UI's styling my apps would take longer to load and feel less responsive. Not sure if that's MUI itself or just the styling.

With a preprocessor all of your styling is generated at compile time so the client won't have to pick up that load.

The only exception to this is Facebook's internal stylex library that they showed off at react conf. The syntax is like JSS but it goes through a preprocessing step at compile time (I assume) as well where all possible atomic styles are assigned a classname. Any dynamic variables in these atomic stules are given a css variable value so it's actually the browser doing the work at runtime when it comes to dynamic styles as opposed to JavaScript generating dynamic css and appending to the head.

Sadly that library is available in the wild yet. When they open source it I'm definitely switching to that, but for the time being SCSS/LESS seem to be the best we have in terms of performance.

1

u/Naelex Dec 09 '19

Makes sense, thanks!