5
My doubt arose after read this question and its answers.
Many Ides provide ways to compile LESS code still in development. In Netbeans, for example, it is possible to configure forever the code .less
is saved, compile and generate the CSS. In projects that need to use some preprocessor I create a structure similar to this:
/assets
/style
/css
| style.css
/less
/build
style.less
| variables.less
| mixins.less
Whenever the directory code style/Less/build is saved, automatically a file .css
is created in /style/css.
So, in HTML just reference the location where the style sheets are, example:
<link rel="stylesheet" href="assets/style/css/style.css"/>
For me this would be the best way, instead of letting this processing be done on the device client who would need:
- Download the LESS file
- Download the script that compiles this code (suppose you have several other scripts to download as well)
- Compile code and turn it into CSS
- Display the CSS
I’m a little while using LESS, but I only see this practice being advantageous if by chance a LESS file is lighter than a CSS (and look there).
So, my doubts:
- A file
.less
is more "light" than a.css
? - When compiling the code on the user’s computer is the best choice?
- What benefits/harms I have when choosing to compile the
.less
of client side?
Great answers. I just wanted to add one more piece of information that might be useful. As Netbeans and Grunt have been cited, I want to cite Sublimetext, which with the right plugins installed, also compiles LESS every SAVE(Ctrl+S). I don’t know exactly what it does, but I installed the following plugins to work with LESS in Sublime: Lessc Less-Build Less2css Sublimeonsavebuild
– Angelo Scali