Less vs CSS-On-Diet
When comparing Less vs CSS-On-Diet, the Slant community recommends Less for most people. In the question“What are the best CSS preprocessors/postprocessors?” Less is ranked 3rd while CSS-On-Diet is ranked 15th. The most important reason people chose Less is:
Because Less has a lightweight feature set, is syntactically similar to CSS and can be run client side with file conversion on a page reload, it is easy to pick up by anyone familiar with CSS & the very basics of JS. Also, Less has detailed and well-organized documentation, GUI apps that can watch and compile code for you and a huge, active and helpful community.
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easy to learn
Because Less has a lightweight feature set, is syntactically similar to CSS and can be run client side with file conversion on a page reload, it is easy to pick up by anyone familiar with CSS & the very basics of JS.
Also, Less has detailed and well-organized documentation, GUI apps that can watch and compile code for you and a huge, active and helpful community.
Pro Familiar CSS style syntax
The LESS syntax is essentially the same as CSS with extensions for dynamic behavior such as variables, mixins, operations and functions.
Variables:
@color: #4D926F;
#header {
color: @color;
}
h2 {
color: @color;
}
Mixins:
.rounded-corners (@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
-o-border-radius: @radius;
border-radius: @radius;
}
#header {
.rounded-corners;
}
#footer {
.rounded-corners(10px);
}
Nested Rules:
#header {
h1 {
font-size: 26px;
font-weight: bold;
}
p { font-size: 12px;
a { text-decoration: none;
&:hover { border-width: 1px }
}
}
}
Pro Modern features and mixins
Less contains the base feature-set for a CSS preprocessor:
- Nesting
- Variables
- Basic mathematical operations
- Color functions
- @import
- Basic type functions
Pro Popular
Less is one of the most popular preprocessors due to being the easy to learn and its use in Twitter Bootstrap.
Pro Less is written in JavaScript
Many web developers are familiar with JavaScript and because Less is written in JS, it can be processed client side making the set-up easy.
Pro GUI apps
Apps such as Crunch, SimpLESS, WinLess, Koala, CodeKit, LiveReload or Prepros will watch and compile less.js for you.
Pro Good IDE support
IDEs such as VS Code, Visual Studio and WebStorm (and other JetBrains IDEs) support LESS either natively or through plugins.
Pro Fast to read and write CSS
Works like Emmet, shorting CSS keywords, but it's not limited only to writing. Also modifying and reading COD(CSS-On-Diet) files is faster.
Pro Easy to learn and use
Doesn't require programming skill to work with variables, mixins, media breakpoints
Cons
Con Less uses '@' to declare variables
The '@' symbol is used with Less to declare variables. However '@' already has meaning in CSS, as it is used to declare @media queries and @keyframes. This can result in some confusion when reading the code.
Con calc() requires interpolation
Con Limited support of conditionals
Less currently has limited support of conditionals such as ternary operators.
Con No custom functions
Less does not offer custom functions and instead requires the use of mixins. This is limiting in many ways - Functions cannot be called on shorthand values, they cannot return a value, and code needs to be repeated depending on where the mixin is needed.
Con Noisy syntax
Many unnecessary characters such as the following:
{}:;@
Con No loop and conditionals block
Con It's difficult adjusting to different keywords
The keywords are shortened to 3 letters. For example, "background-color" becomes "bac" and "max-width" becomes "maw". These keywords are far less intuitive than their original form and make the CSS much less readable for those who don't know CSS-On-Diet.
Con Extremely limited adoption
CSS-On-Diet has just 7 stars on Github and a very small adoption rate. For an open source project this usually means less bugs reported, lesser documentation and few third-party learning resources.