简体   繁体   中英

Less Loop basically downgrades performance?

I made this less loop to generate css code needed to a specific task. (included at bottom of page). Is it safe to say that writing less-loops reduce development time but also generates unnecessary code styles? I can see a lot of benefits of using this technique but none of them include performance optimization aspects.

    @items : 12;
@color-base : red;
@slice : 30deg;
.looop (@i) when (@i>0){
  .looop(@i - 1);
  li:nth-child(@{i}){
    transform: rotate((@i*@slice)-30) skewY(-2*@slice);
    .text {
      background  : spin(@color-base, 30);
    }
  }
}
.looop(@items);

You can optimize it a bit:

@items : 12;
@excluded-items: 1, 2, 5;
@color-base : red;
@slice : 30deg;

.looop (@i) when (@i>0) {
  .looop(@i - 1);

  li:nth-child(@{i}){
    transform: rotate((@i*@slice)-30) skewY(-2*@slice);
  }
}

.looop(@items);

li {
  .text {
      background  : spin(@color-base, 30);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM