运行较少的服务器端与客户端

发布于 2024-12-13 23:55:58 字数 59 浏览 5 评论 0原文

与服务器端相比,在客户端运行 LESS 框架有哪些优点/缺点?如果在客户端运行页面加载时间会受到影响吗?

What are the advantages / disadvantages to running the LESS framework client-side vs. server-side? Does page load time take a hit if you run it client-side?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

執念 2024-12-20 23:55:58

在服务器上,您必须更加小心缓存控制标头,并且会牺牲一点 CPU 能力。

在客户端,如果 JS 不可用,它就会中断。

(对于您的生产系统)在构建时执行此操作并仅提供静态 CSS。这是高效且可靠的。

On the server, you have to take more care with your cache control headers and you sacrifice a bit of CPU power.

On the client, it breaks if JS isn't available.

(For your production systems,) do it at build time and just serve up static CSS. That's efficient and reliable.

短叹 2024-12-20 23:55:58

使用 ASP.NET MVC 4.0 捆绑,您可以使用:

var bundle = new StyleBundle("~/Content/style").Include(
    "~/Content/myStyles.less");
bundle.Transforms.Add(new LessTransform());

bundles.Add(bundle);   

一切都将得到很好的处理。缓存、转换(服务器端)、捆绑和...

Using ASP.NET MVC 4.0 Bundling you can use:

var bundle = new StyleBundle("~/Content/style").Include(
    "~/Content/myStyles.less");
bundle.Transforms.Add(new LessTransform());

bundles.Add(bundle);   

Everything will be handled very nicely. Caching, Transforming (server-side), bundling and ...

没︽人懂的悲伤 2024-12-20 23:55:58

客户端:

优点:

  • 更好的调试
  • 可能更容易开发

缺点:

  • 带宽较慢
  • cpu 性能较慢(可能影响移动设备)
  • 没有 JS

中断 服务器端:

优点:

  • 速度更快
  • 客户端 JS 独立

缺点:

  • 一点实施更多工作

我的建议:

永远不要在生产中使用客户端。然而,在开发过程中,编译较少的客户端可能非常有用。

Client-side:

Advantages:

  • Better debugging
  • May be easier in development

Disadvantages:

  • Slower in terms of bandwidth
  • Slower in terms of cpu performance (may affect mobile devices)
  • Breaks without JS

Server-side:

Advantages:

  • Faster
  • Client JS independent

Disadvantages:

  • A little bit more work to implement

My advise:

Never ever use client side in production. In development it may however be very useful to compile less client side.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文