DEV Community

Discussion on: What is your opinion on CSS in JS and generating Static sites from JS frameworks?

Collapse
 
dallgoot profile image
dallgoot

CSS in JS is the way to return to the soup-coding behaviour we extracted ourselves from in the first times of internet dev.
JS should only be used to alter dynamic properties when needed ie: when can NOT set (all) fixed values in CSS.
Separation of concerns is important or else we will, again, end with some code that is a mess and you don't even know where to search for updating/correcting something.
I personnaly am sick when i see stuff like :

function open(element){
    $(element).css('height', '77px');
}
Enter fullscreen mode Exit fullscreen mode

that's a mistake not only because you have to search JS code in case of change but because you are taking responsability for something that is not your job : design.

Just change the class, ask the designer to make another class and everyone keeps their responsaility and work on their duties.
As a final note many coders have the false idea that design is just a matter of coulours and fonts : IT IS A NOT, it's a job , people go to school for this, trust them and focus on code.