DEV Community

Discussion on: CSS: From Zero to Hero

Collapse
 
aspittel profile image
Ali Spittel

Hey, I wouldn't suggest this method for a couple reasons:

  1. it's going to be less performant than writing CSS in the first place, and it will likely either block page loading or create a jump in styling once the styles are applied.
  2. the separation of concerns. It's usually best practice to separate out your code into different files for HTML/CSS/JS so that you don't have one really long file to look through, plus then you know where to go to debug an issue with one of the pieces!

CSS in JS is a valid thing, but I would use a library built for that so that your code is more performant and follows best practices!

Collapse
 
pvw_nl profile image
Peter 👨🏻‍💻

Hi Ali, Dirk,

I think you've missed a very important argument why you shouldn't do this at all. What about a client ho has disabled javascript (because reasons)? He/she is able to see your page, but with the wrong styling.

JS is good for doing the extra mile, please use CSS for the things it was intended. We can even make animations and transitions with CSS today!

Good luck :)