最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Do you recommend against javascript based LESS? - Stack Overflow

programmeradmin2浏览0评论

After I watched this NetTUTs video, I'm very interested in trying out the LESS.js method shown.

Other than the obvious, "What if the user doesn't have javascript enabled?", or "There's going to be a small performance hit"... is there a reason this cannot be used in production?

LESS essentially looks like what CSS should be...

After I watched this NetTUTs video, I'm very interested in trying out the LESS.js method shown.

Other than the obvious, "What if the user doesn't have javascript enabled?", or "There's going to be a small performance hit"... is there a reason this cannot be used in production?

LESS essentially looks like what CSS should be...

Share Improve this question asked Jun 25, 2010 at 0:33 ChaddeusChaddeus 13.4k30 gold badges107 silver badges166 bronze badges 4
  • 2 Personally I do that kind of stuff at build time, because it's really not that hard. – Pointy Commented Jun 25, 2010 at 0:37
  • @Pointy - Do you have any examples of what you do? Anything in .NET (I'm building MVC 2.0 based apps). Thanks! – Chaddeus Commented Jun 25, 2010 at 0:51
  • 1 I would just set up a post-build action that runs the Ruby lessc piler on your .less files, transforming them to regular .css files. – Dean Harding Commented Jun 25, 2010 at 1:28
  • sorry no .NET examples - I build in a Java world, and I use Freemarker to pre-process .CSS files – Pointy Commented Jun 25, 2010 at 3:02
Add a ment  | 

3 Answers 3

Reset to default 6

I can't see any reason why it should be used in production. It makes more sense to run this as a build script, then make the output (regular CSS) available on a cached cookie-free domain. Then, it works fine without JavaScript and doesn't require JavaScript processing (which will be slower than the CSS parsers written in tuned native code) on every page load.

Yes, if people with Javascript disabled is a concern, then I would remend against the Javascript-based LESS. Personally, I see no advantage in it over the Ruby-based one, since you really only need Ruby installed on your development machine - once you pile the .less file to a .css, there's no difference between a LESS-piled .css file and "hand-written" one.

I haven't tried in production, but there may be some interesting use cases around LESS variables. For example, you could change underlying less variables that in turn change a bunch of dependent CSS rules (relative widths/heights for example).

See https://stackoverflow./a/8742705/255961 for interesting patch that makes it very easy to change them using a simple modifyVars() function.

With it you could change your Bootstrap grid size and everything that depends on it with a single, local JS call:

less.modifyVars({
  '@gridColumnWidth': 50px
});
发布评论

评论列表(0)

  1. 暂无评论