Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should common LESS elements be combined in the CSS output? #2877

Closed
jt000 opened this issue Apr 23, 2016 · 2 comments
Closed

Should common LESS elements be combined in the CSS output? #2877

jt000 opened this issue Apr 23, 2016 · 2 comments

Comments

@jt000
Copy link

jt000 commented Apr 23, 2016

Take the following example (repro'd with 2.5.3):

.nav {
  min-height: 20px;

  > a {
    color: blue;
    text-decoration: none;
  }
}

.nav {
  display: block;

  > a {
    padding-top: 3px;
  }
}

.nav > a {
  padding-bottom: 2px;
  color: green;
}

.nav-sm {
  .nav;

  > a {
    color: red;
  }
}

The above LESS creates the following CSS

.nav {
  min-height: 20px;
}
.nav > a {
  color: blue;
  text-decoration: none;
}
.nav {
  display: block;
}
.nav > a {
  padding-top: 3px;
}
.nav > a {
  padding-bottom: 2px;
  color: green;
}
.nav-sm {
  min-height: 20px;
  display: block;
}
.nav-sm > a {
  color: blue;
  text-decoration: none;
}
.nav-sm > a {
  padding-top: 3px;
}
.nav-sm > a {
  color: red;
}

From this example, the .nav, the .nav > a, and .nav-sm > a are created multiple times which could lead to inheritance\ordering differences on different browsers. Should they be combined into a single .nav, .nav > a, and .nav-sm > a elements to be more explicit in the value & decrease the overall size of the CSS?

@jt000 jt000 changed the title Should child elements be combined? Should common LESS elements be combined in the CSS output? Apr 23, 2016
@seven-phases-max
Copy link
Member

seven-phases-max commented Apr 23, 2016

See #930. In short: no, Less does not analyze outcoming CSS (except some trivial stuff) and thus cannot perform any optimization of that kind for free. Considering you can get these optimizations with clean-css, this feature is most likely to stay beyond Less scope.

are created multiple times which could lead to inheritance\ordering differences on different browsers.

No, no matter how many times .nav-sm > a appears in the output, inheritance/ordering remains the same in all conformant browsers.

@seven-phases-max
Copy link
Member

Merging to #930.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants