运行LESS服务器端与客户端

时间:2022-05-18 15:13:35

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?

运行LESS框架客户端与服务器端的优点/缺点是什么?如果您在客户端运行页面加载时间会受到影响吗?

3 个解决方案

#1


18  

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

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

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

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

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

(对于您的生产系统,)在构建时执行它,并提供静态CSS。这是有效和可靠的。

#2


0  

Using ASP.NET MVC 4.0 Bundling you can use:

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

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 ...

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

#3


0  

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)
  • 在CPU性能方面较慢(可能会影响移动设备)

  • Breaks without JS
  • 没有JS的休息

Server-side:

Advantages:

  • Faster
  • Client JS independent
  • 客户端JS独立

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.

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

#1


18  

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

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

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

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

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

(对于您的生产系统,)在构建时执行它,并提供静态CSS。这是有效和可靠的。

#2


0  

Using ASP.NET MVC 4.0 Bundling you can use:

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

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 ...

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

#3


0  

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)
  • 在CPU性能方面较慢(可能会影响移动设备)

  • Breaks without JS
  • 没有JS的休息

Server-side:

Advantages:

  • Faster
  • Client JS independent
  • 客户端JS独立

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.

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