Do you recommend against javascript based LESS?

后端 未结 3 2014
野的像风
野的像风 2021-01-06 09:14

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

相关标签:
3条回答
  • 2021-01-06 09:57

    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.

    0 讨论(0)
  • 2021-01-06 10:06

    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.com/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 讨论(0)
  • 2021-01-06 10:10

    Yes, if people with Javascript disabled is a concern, then I would recommend 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 compile the .less file to a .css, there's no difference between a LESS-compiled .css file and "hand-written" one.

    0 讨论(0)
提交回复
热议问题