4 ms·
This sounds like an awful idea. Just put your CSS in a .css file where it can be cached, delivered by CDNs and can easily be edited in a single place. Separat
by martin_a 8y ago
This sounds like an awful idea.
Just put your CSS in a .css file where it can be cached, delivered by CDNs and can easily be edited in a single place.
Separation of content and presentation has been around for a good reason. One should always avoid mixing logic and design because it will break some day, no matter how well you think you handle it.
- ggregoire 8y ago> Just put your CSS in a .css file where it can be cached, delivered by CDNs .js files are cached and delivered by CDNs too. > can easily be edited in a single place If you change the name of a class (or add a new one, delete another one, edit the structure of the component, etc...), then you have to open and edit 2 files. With author's solution you don't. The CSS is collocated with the component. > Separation of content and presentation has been around for a good reason. One should always avoid mixing logic and design Author is talking about putting the React component (presentation) and its CSS (presentation) in the same file. He's not mixing business logic and design.
- pmlnr 8y ago> .js files are cached and delivered by CDNs too. Not in 2019, in the age of excessive A/B testing, where every page load gives you a different set of JS.
- beefalo 8y agoIf you need caching then you would likely server render your page and that would inline all of the critical css to be cached as well. Writing your css in JS files also does nothing to prevent you from separating content and presentation. You can write components that just handle styling. I see more problems with separation in css where you end up with one giant file that handles the whole site.