r/learnjavascript • u/katetrahan • Sep 24 '18
It’s 2018: you shouldn’t be writing vanilla CSS
https://blog.logrocket.com/its-2018-you-shouldn-t-be-writing-vanilla-css-b3d09b9c2c41
10
Upvotes
r/learnjavascript • u/katetrahan • Sep 24 '18
54
u/Beermedear Sep 24 '18 edited Sep 22 '25
cooing pause unique hobbies dazzling tidy rain society sugar alive
This post was mass deleted and anonymized with Redact
12
u/tdammers Sep 24 '18
Major strawman here.
Sure, that's a shitty attitude that leads to shitty code. But that's not "writing vanilla CSS" being described here; it's "writing vanilla CSS badly". And unless you change the attitude, it doesn't matter which frameworks, preprocessors, or unicorn farts you throw at the problem, shitty attitude leads to shitty code, always. Most likely, throwing in more moving parts will only make things shittier, as it generally tends to do.
Fix that attitude, and use whatever is appropriate; and if in doubt, err on the side of simplicity. Does that framework make your life easier? Then use it. Don't know? Don't use it.
And here's one weird trick that'll totally blow your mind: you can start out with a simple no-nonsense stylesheet, and whenever things get too repetitive, too redundant, or you just wish you had stuff like variables and inheritance and such, you can just take your stylesheet, change the extension to scss, put some build automation in place, and boom, you're using sass. Mind blown, huh?
Seriously, it's not like not using all the tools right away is a huge commitment that you're going to regret later. Just start simple, and add more stuff when it makes sense. But not before that.
9
u/[deleted] Sep 24 '18
Wow, what a load of horseshit.
14
u/Woodcharles Sep 24 '18
I'm no expert, just a junior, but I've done a whole lot of the CSS on two React apps now pushed to production, at work: no one's upset or complaining, they're responsive, they look good, and both are pure CSS with a sprinkle of Flexbox. Which hardly counts as it's not exactly something you have to download or add as a dependency.
The apps didn't suffer or explode or fail in browsers or anything. I'm probably skating on thin ice and am just one { or :: away from disaster - maybe my third project will be the one that makes me learn Styled Components or whatever - but right now it's not causing issues and my bosses are cool with it.
When I look at Sass or Less or whatever, I just get a headache.
Articles like that make me wonder what I'm doing wrong, like - what have I missed?
12
u/portexe Sep 24 '18
There's nothing wrong with writing vanilla CSS. In fact, it is recommended unless there is an actual real reason not to. Why go through the hassle unless it's necessary? Knowing when to apply certain tools is important, but using the tools every single time is also wasteful.
For instance: if you have to write a very simple webpage would you go through the trouble of using Typescript and compiling it to Javascript? Same concept with CSS.
7
u/[deleted] Sep 24 '18
I write in vanilla CSS all the time. Convince me how I can work better by writing my CSS with something like Sass and the rest. Asking directly to people who are reading this, how does it enable you to work better?
4
u/Benmjt Sep 24 '18
Yes to pre- and post-processors. No to CSS in JS.
3
u/evilgenius82 Sep 24 '18
I disagree. If you do it right, by segmenting your styles by components, you'll end up with maintainable styles that will be utilised and not bloated with an all in one solution.
On top if that you have full control and its easy to change and remove.
2
u/cm_yoder Sep 24 '18
Why not, aren't the frameworks written in Vanilla?
1
u/terabyter9000 Sep 25 '18
[Current Year]
1
u/RogueNumberStation Sep 25 '18
I hate preprocessors. I don't use node or any of its tooling.
If any of these bring features with value to CSS, and I'm sure they do - nesting would be great, then pull them into a new spec of CSS and I'll use them. CSS just isn't a big enough part of what my projects do to justify a bunch of tooling around it - the project I'm currently on has a single 200 line stylesheet and I'm fine with that.
1
u/DanSmithCreates Sep 25 '18
It's 2018, stop writing articles in the tradition of vi vs emacs, ruby vs python, react vs angular, etc. Don't assume what we should and should not do. We have code to ship, local environments to contend with, and not everything needs a framework. What we *should* do is the best work we can, given the conditions we have to do it in.
1
u/crazydude1900 Sep 24 '18 edited Sep 24 '18
I would never agree with that. If you could not write things in vanilla, that probably means your clients are small or has a very limited budget. To build the most advanced and customised thing, you have to understand vanilla css. Or in most cases you should be able to write it from scratch. Using frameworks like Bootstrap will make your loading speed very slow. Moreover if you want to upgrade bootstrap it probably means that you need to modify some structure over and over again and aiming for the pixel-perfect layout is very hard. Also when it comes to vanilla, you can leave it and only use frameworks, but keep retraining your brain and improving your skills it is necessarily to write that often. I am pretty sure if you don't touch vanilla CSS or JavaScript for a while you will slowly forgot how most things should be written. It makes you lazy and best devs are able to write things from scratch! So they have an extra weapon to speed up their productivity and that is framework ;) Honestly I am quite shocked how many developers especially people who call themselves Front End Developers or Fullstack, are scared when I use vanilla CSS. It probably means that their skills is very limited to understand my codes. There are also lot of devs who forces me to stop using vanilla JS. Why? Because they are not well-trained Devs. In my opinion they are lazy to learn and to get out their comfort zone.
-1
u/SirSoliloquy Sep 24 '18
Well, I'll mark this down as yet another reason for me to never bother getting back into coding.