Live data from Hacker News

The Debate Around “Do We Even Need CSS Anymore?”

css-tricks.com

11–20 of 67 posts

Re: The Debate Around “Do We Even Need CSS Anymore?”

#11
post #4

I've been using inline everything since templates (ejs) came into existence. Once you have templates you're only editing one location anyway. The biggest problem with CSS is it's really easy to add, and close to impossible to delete (detecting potential repercussions is hard). Sure there's performance issues, but most of the time your developer/maintenance time is worth the the extra bytes.

But, is that extra development time worth the time your visitor loses whilst page rendering? If it's a significant amount, I would say no.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#12
You lose the benefits of style caching with inline or dynamically applied styles, and inlining makes each HTML payload larger. Also, applying virtually all of your styles with JavaScript, after the DOM has already finished loading, wastes CPU cycles and just feels like going against the grain of CSS to me. You make a few arguable gains with this technique, but I feel it might be throwing the baby out with the bathwater.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#13
post #8

CSS preprocessors are fine. Processors only understand binary but noone programs in binary today. If CSS become the binary of tomorrow, it's fine. Inlining CSS is stupid, it makes your page bigger, less flexible, doesn't use browser caching technics, and didn't solve the problem at all (or make it worse...). CSS with Javascript is even worse, as it will be slow as fuck, hard to maintain, and equivalent to directly wr…

So many wrong statements.

The performance differences, between CSS styles applied from a JS file and a CSS file are very small on modern browsers, with JS being faster sometime.

JS files are cached.

Preprocessors are not fine, they complicate and slow down the development process.

Inlining CSS is not stupid, OP discusses the numerous advantages it brings...

Re: The Debate Around “Do We Even Need CSS Anymore?”

#14
post #7

The separation of concerns argument is dogmatic here. Just because it used to be that you should keep presentation in your CSS and behavior in your javascript, doesn't mean that's a universal truth. It's a good abstraction to separate presentation from behavior, but that doesn't mean one has to be done in one language and the other in a different one. Separating the concerns just by partitioning them within your code…

> One is that your page should work without javascript

Universal rendering would send straight HTML with inline styles to the browser. And plenty of web applications need JS to function properly.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#15
post #4

I've been using inline everything since templates (ejs) came into existence. Once you have templates you're only editing one location anyway. The biggest problem with CSS is it's really easy to add, and close to impossible to delete (detecting potential repercussions is hard). Sure there's performance issues, but most of the time your developer/maintenance time is worth the the extra bytes.

Sounds like an opportunity for IDE makers. Add plugins to track CSS/HTML/templating, "where used" tools, and refactoring to push frequently repeated styles up into a main CSS file, or rarely used styles down into the few elements using it. Hopefully, there are few enough classes and styles injected from a long js code chain that you can manually check the things the IDE misses. JetBrains IDEs are surprisingly good at…

I doubt IDE's could really do much with it -- adding and removing classes dynamically means it can answer the question "is this used?" but it can never answer the question "is this unused?" Plus there's about 4000 template languages being invented every second, that the IDE would need to not just highlight, but intelligently parse.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#17

You lose the benefits of style caching with inline or dynamically applied styles, and inlining makes each HTML payload larger. Also, applying virtually all of your styles with JavaScript, after the DOM has already finished loading, wastes CPU cycles and just feels like going against the grain of CSS to me. You make a few arguable gains with this technique, but I feel it might be throwing the baby out with the bathwat…

You can get around this by using compilation tools, just like Compass does.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#19
>What is the alternative to CSS then? The alternative is inline styles. ... The idea is you apply styles to elements through JavaScript.

But if you have a non-trivial app with thousands of elements across hundreds of pages, people will inevitably want to "tame", "organize", "consolidate", etc those inline styles into some coherent taxonomy to enforce consistency.

Wherever and however the programmers decide to store this "consistency taxonomy" (e.g. into special .json files instead of .css files), they've just reinvented "CSS" by another name.

The 3 complaint bullet points at the top of the essay would then apply to the adhoc-this-is-not-CSS-but-it-acts-like-CSS system.

Re: The Debate Around “Do We Even Need CSS Anymore?”

#20

You lose the benefits of style caching with inline or dynamically applied styles, and inlining makes each HTML payload larger. Also, applying virtually all of your styles with JavaScript, after the DOM has already finished loading, wastes CPU cycles and just feels like going against the grain of CSS to me. You make a few arguable gains with this technique, but I feel it might be throwing the baby out with the bathwat…

You can get around this by using compilation tools, just like Compass does.

So, create a problem, and then solve it?
Post reply on HN