Live data from Hacker News

Less.js will obsolete CSS

fadeyev.net

61–70 of 131 posts

Re: Less.js will obsolete CSS

#61
post #21
post #20

One thing puzzles me: If LESS is essentially a template language specialized for CSS, why not reuse the template engine that you use in your application anyway? That way, you'd also have the benefit of defining often-used attribute values (e.g. colors) in a variable, and you could also group often-used combinations of attributes together in a variable or sub template.

I wonder why there is no general "template" language that you can use on any text/source file. For example, I'm writing a lot of AutoHotKey code lately, and I find myself wishing I had some of the expressive power of Python so I wouldn't have to repeat things. I'm seriously considering writing a Python-based "Preprocessor" language which lets me drop in Python code on any file, and deals with transforming it into the…

We're going back to M4 now, but with python?

Re: Less.js will obsolete CSS

#64
post #4

Literally the only problem with CSS itself is that it doesn't have defines. Every other problem is just browser implementations.

There are plenty of problems with CSS. You can't specify the width of an inline element, for one. That alone prevents a lot of reasonable layouts, like tables. Also problematic is a standards body that ignores this use case! In this case, they protect the writer from over-filling some boxes with more boxes. But that would at least be visible - in this case, the workarounds end up far worse.

If you want a table layout, why not just use a table? Or you can use display: inline-block if you want to give a width to an inline element.

Re: Less.js will obsolete CSS

#65
post #16

Running a compiler in the browser in production will never be a good idea. If you care about the speed that your website displays -- and you should -- the slowdown caused by parsing, processing, and concatenating large amounts of CSS will dwarf over-the-wire time. People who seriously care about the usability of their sites have been spending a lot of effort recently figuring out how to get load times as fast as poss…

Less.js will cache the CSS on modern browsers after the first load using HTML5 local storage, so subsequent loads aren't an issue. First load is also very fast and won't make a huge difference. Like you, I wouldn't normally recommend running the compiler live but the performance here is really impressive. Please don't assume how fast Less.js is before you try it.

Re: Less.js will obsolete CSS

#66
post #13

Sensationalist link-bait headlines have no place here IMHO.

59 points and (at the time of writing) top post would indicate some disagree

Of course they do. That's the problem with democracies. They all turn into a cesspit of idiocy unless you keep control.

Re: Less.js will obsolete CSS

#67

Earlier quoted context omitted.

I demand a benchmark. Saying that something is just false without numbers to back it up is not something I have high trust in, and is the start of the gossip that causes internet wars. First back it up with numbers, then we talk.

As it's cached, it's only the first load that will have the lag. I'd guess it will be quite small as well. If the CSS makes heavy use of mixins and the nesting ability then the lag may even be smaller than the time to transfer the compiled CSS. Maybe.

First load is where it counts! This is when users first see your site: their first impression. This is an important time that should be kept as fast as possible. Subsequent loads, for most sites, are likely not as important speed wise.

Remember, we have to design our sites as if the user is poised over the back button.

Re: Less.js will obsolete CSS

#68
Is this really solving a problem? I mean CSS itself has issues but wrapping a developer centric toolkit around it doesn't seem to help. In my view CSS is a necessary evil but it is also primarily used by designers. Forcing them to use variables and learn classes and adhere to another syntax would seem counter productive to most of the gains.

Re: Less.js will obsolete CSS

#69
post #3

Admitedly, I'm a relative n00b when it comes to development but seriously "I do not get it". There doesn't appear to be much in the way of reduced syntax, at least not in the example provided. Can someone explain why this is better or clearer than CSS?

LESS or Sass are great in specific use cases. They're especially useful when you're using a lot of CSS visuals (where you have to write out about 3-5 lines just for one property because each browser has it's own version, i.e. -moz-, -webkit-, etc). With LESS you can create a mixin that does this thing (e.g. rounded corners) that also takes an argument and just call it in all the places where you need rounded corners. Sometimes you want to re-use the same color over in many different places. If you change your mind, you have to go back and change it everywhere, making sure you don't miss a spot. Nesting makes the code much more organized (you have to try it to see) since you can see which bit of code relates to which area of the page. It's just neater and easier to view. Each of these benefits on its own isn't very big, but when you start saving time here and there they do add up, especially on large stylesheets.

Basically, it's not really about reducing syntax or size of the file (which does get smaller for large stylesheets), it's all about making the stylesheet easier to build and maintain.

Post reply on HN