Frontend Development

Hello guys, Any suggestions which approach offers better readability, maintainability, and faster performance in front-end development: using plain CSS, a CSS preprocessor, or a CSS framework?
25 Replies
Wonderbear
Wonderbear•8mo ago
This is a very opinionated topic with many subjective answers. In terms of performance, it should'nt make a difference. I would advise against a pre processor - css itself is very feature rich and imho already complex enough.
Joao
Joao•8mo ago
I think there's still an argument for using pre-processors, even though CSS now has many features like nesting and such. Mixins is a big favorite of mine, and that alone makes it absolutely worth it, for me anyway. Another big plus is file organization as you can import files as needed. This also exists in CSS natively, but it will require making additional requests to fetch those files. Not a big impact on loading times, but it's there. In terms of performance it doesn't really matter. The performance comes from how you write the code, rather than with what. In short, there's nothing to lose by using a pre-processor while still gaining a few improvements here and there. For me it's a no brainer, there's no reason not to use it.
Wonderbear
Wonderbear•8mo ago
Bundler would take care of that anyway Except for another dependency tree with another syntax and increased compiler times.
Joao
Joao•8mo ago
I don't think those arguments weight very much: the syntax is nearly identical, only differs in the additional features it provides. Compiler times increased... by how much? During development it's fast enough that it's done by the time I switch between editor and browser. At build time, it's negligible. And if you're troubling yourself by including a bundler in your toolkit, you are already including additional dependencies. Why not also a preprocessor?
Wonderbear
Wonderbear•8mo ago
I mean its okay to use it, i just think its not necessary. But if it makes the work so much easier for you, then go ahead
Joao
Joao•8mo ago
I agree, and like you said, very opinionated topic 😄
Wonderbear
Wonderbear•8mo ago
I am a big fan of tailwind btw (and yes I know it forcibly comes with a css pre processor) its greatly readable and maintainable imho
Joao
Joao•8mo ago
We had a great discussion about that here: https://discord.com/channels/436251713830125568/1195001775049158687 I think Tailwind gets a lot of deserved criticism, but also a lot of undeserved hate. It has it's place, and can be immensely useful for quick iteration and prototyping. It's not my preferred tool but it's quite handy.
Wonderbear
Wonderbear•8mo ago
This discussion is definitely too long for me to catch up, but if we're talking about beginners, I generally recommend not using any frameworks or libraries at all and instead learn the bare basics. Tailwind is very close to vanilla javascript - much closer than "styled" libraries like bootstrap or others that come with a predefined design system. You cant use tailwind without understanding and knowing css already. Tw will not give you a readily styled button - you still have to know all css properties to style the button with tw classes.
Jochem
Jochem•8mo ago
I agree that you need a good css base to use tailwind, I just don't see the value of tailwind once you have that base. It just makes your HTML unreadable, and the whole point of CSS is to have that cascade and to not repeat yourself styling multiple elements similarly, and you lose that by faking inline styles like you do with tailwind to weigh in on the original question: Plain CSS is going to give you better readability (not everyone will have experience with your framework of choice) and performance (you won't have any extra CSS to support features of a framework you may not use). I'd argue maintainability is higher too, a framework update can be a major pain. the selling point of frameworks is none of those points though, it's all in the developer experience. People use bootstrap because they want to just go <a class="btn btn-primary"> and have something that looks alright for 99% of cases.
Joao
Joao•8mo ago
For most tasks I still prefer CSS or SCSS, but I agree with what Jochem says about the developer experience. I've found that for any code that I didn't write myself, or after a while, Tailwind becomes a nuance to manage. When you are the one writing the code on the other hand, it doesn't look cluttered and it's quite comfortable to use. But for beginners: always learn the basics, and learn them properly. No matter if it's HTML, CSS or JavaScript. Frameworks are cool and all but they are much more useful when you know how to use them effectively, which means learning the fundamentals they are built on.
Wonderbear
Wonderbear•8mo ago
Are you using component frameworks or template engines? I think that makes the difference on how one views this topic
Jochem
Jochem•8mo ago
personally neither
Wonderbear
Wonderbear•8mo ago
You're just making static html pages?
Jochem
Jochem•8mo ago
no, just using vanilla CSS with either PHP or sveltekit
Wonderbear
Wonderbear•8mo ago
Ah okay, that was my question. If you're using Sveltekit, then you're using a component framework. If you're using php, then you're using a template engine
Jochem
Jochem•8mo ago
ah, I thought you were talking about something-something css, I misunderstood. I've used plenty of PHP without templating engines though
Wonderbear
Wonderbear•8mo ago
Tailwind only really starts to shine when using it in combination with components, thats why I asked
Jochem
Jochem•8mo ago
see, I don't disagree, but only if the framework in question doesn't support scoped CSS
Wonderbear
Wonderbear•8mo ago
Scoped css is definitely a valid alternative to tailwind
Jochem
Jochem•8mo ago
which is part of why, for me and pretty much most people that don't use React, Tailwind is kind of a pointless abstraction to solve a problem that's better solved with just using scoped css in your component framework
Wonderbear
Wonderbear•8mo ago
I dont agree but I dont wanna fight with you over such a meaningless thing. I use tw with Svelte and found it to make everything easier. Especially layouting and working with colors is great in tailwind.
Jochem
Jochem•8mo ago
yeah, fair enough
Joao
Joao•8mo ago
The themes in Tailwind makes things so much easier for me. A big plus for it tbh
Wonderbear
Wonderbear•8mo ago
An alternative may be scoped styles and a thought out structured css variable system + a bunch full of global layouting classes for flex, grid, positioning, etc
Want results from more Discord servers?
Add your server