你建议不要使用基于 javascript 的 LESS 吗?
在我观看了这个 NetTUTs 视频,我对尝试所示的 LESS.js 方法非常感兴趣。
除了显而易见的问题之外,“如果用户没有启用 javascript 怎么办?”或“性能将会受到轻微影响”……这是否有原因不能在生产中使用?
LESS 本质上看起来就像 CSS 应该是的......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我看不出有任何理由应该在生产中使用它。将其作为构建脚本运行,然后使输出(常规 CSS)在缓存的无 cookie 域上可用更有意义。然后,它可以在没有 JavaScript 的情况下正常工作,并且不需要在每次页面加载时进行 JavaScript 处理(这将比用调整后的本机代码编写的 CSS 解析器慢)。
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.
是的,如果有人担心禁用 Javascript,那么我会建议不要使用基于 Javascript 的 LESS。就我个人而言,我认为它比基于 Ruby 的文件没有任何优势,因为您实际上只需要在开发计算机上安装 Ruby - 一旦您将 .less 文件编译为 .css,与 LESS 编译的 .css 文件没有区别和“手写”一份。
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.
我还没有在生产中尝试过,但围绕 LESS 变量可能有一些有趣的用例。例如,您可以更改底层的 less 变量,从而更改一堆相关的 CSS 规则(例如相对宽度/高度)。
请参阅 https://stackoverflow.com/a/8742705/255961 了解有趣的补丁,可以使用它轻松更改它们一个简单的
modifyVars()
函数。有了它,您可以通过单个本地 JS 调用来更改 Bootstrap 网格大小以及依赖于它的所有内容:
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: