News for hackers. Stuff that matters.
Re:Why I Write CSS in JavaScript by zelphirkalt on Monday February 18, 2019 @03:36PM (#19194182)
This is sad. All because people are not able to think of one simple prefix and stick with it when naming CSS classes. How hard can it be? Just use some part or abbreviation of the company name and be done with it. Or better yet: Let third party do that. I always hated that, when someone used Bootstrap on a website and Bootstrap f'ed up all future styling, by assuming it was the only one player in the game. So stupid.

I personally never ever ran into any problem, when I myself named CSS classes and that is because I automatically think about the future and whether a name could conflict with something else, instead of being lazy and typing 3 characters and thinking I did my job. I am simply careful and use prefixes and give unique names, so that it has such a low chance of someone else using that CSS class name, that it simply never happened in practice. So from my personal experience all that mumbo-jumbo about CSS name collisions comes from people not being careful and is a "house made" problem, not a problem of CSS. I never had any need to use JS to do what is CSS's job.

Using JS for doing something CSS should do is furthermore dangerous, since clever people deactivate their JS or block it partially. For me personally, your (not you personally, but you in general, anyone who reads this) JS better comes from your own domain, or it will be blocked by default. If you can live with people seeing your website utterly destroyed by its inability to apply style, then OK, do the styling in JS.

Re:Why I Write CSS in JavaScript by exogen on Monday February 18, 2019 @05:41PM (#19195155)
I'm happy that just prefixing things is working for you. I don't typically have problems on smaller projects.

But I've also been writing CSS since 1997. I've deployed CSS to sites like walmart.com, nfl.com, mlb.com, starbucks.com, twitch.tv, etc. Some of these sites have a lot of third-party widgets on them. I can confidently say that the (multiple) issues with CSS are not a "just do <simple thing X>" type of problem.

Re:Why I Write CSS in JavaScript by sli on Tuesday February 19, 2019 @12:31PM (#19200829)
> I can confidently say that the (multiple) issues with CSS are not a "just do <simple thing X>" type of problem.

I'd go so far to say that almost no (real) problem is that type of problem. Maybe problems that are mostly inconsequential, sure.

Re:Why I Write CSS in JavaScript by threatofrain on Monday February 18, 2019 @03:53PM (#19194340)
People want an interface such that a folder represents all they want to know at that moment about a component. But then someone else may want an interface such that a folder can represent all the styles across the app.

Otherwise I do think that the naming collision problem is really easily fixed.

Re:Why I Write CSS in JavaScript by bobthepanda on Monday February 18, 2019 @04:06PM (#19194459)
You can get the beat of both worlds by having one folder for one component and then a ‘common’ folder.

SASS seems to solve most of the problems i would have with writing basic CSS.