Less should be compiled yet in development?

Asked

Viewed 422 times

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:

  1. Download the LESS file
  2. Download the script that compiles this code (suppose you have several other scripts to download as well)
  3. Compile code and turn it into CSS
  4. 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?
  • 3

    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

1 answer

7


Compiling the Less file while in development is the programmer’s option. I prefer to compile (Grunt does it alone for me). Therefore, even in development, I use the CSS, not the Less files. In production, no doubt the CSS file should be distributed, and not the Less.

Answers to your individual questions:

1. A Less file is no lighter than a CSS file because it needs to be compiled.

2. No. It may be that the user’s browser wants to support files in Less and then your site would be displayed "broken".

3. I believe no benefit. For harm, see items 1 and 2.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.