如何评价lit-html?

1,190 阅读1分钟

来源于知乎问题:如何评价lit-html?

介绍了一个新的库lit-html,github地址

抛砖引玉。

先说结论:不考虑在工程中使用

先看框架的自我优点介绍:

Motivation

lit-html has four main goals:

  1. Efficient updates of previously rendered DOM.
  2. Expressiveness and easy access to the JavaScript state that needs to be injected into DOM.
  3. Standard JavaScript without required build steps, understandable by standards-compliant tools.
  4. Very small size.

简单翻译一下,4个目标:

  1. 快速渲染DOM(评:性能对比还没实锤,『performance benchmarking is just starting』,个人判断对于中后台的重渲染性能还是很担忧的,C端的渲染应该还可以,类似于artTemplate)
  2. 很容易接入状态管理工具(评:这个不错,减少了框架的耦合性,想用响应式(Mobx)或者不可变式(Redux)状态管理工具都行)
  3. 不需要构建工具(评:意味着不高的浏览器兼容性,面向未来的技术)
  4. 很小的体积(评:更适合C端)

总体看下来收益不大,但第3点对我国国情很致命

其他:

  • 支持promise注入(评:鸡肋,直接在view层调promise,只适合小应用。api复用怎么办?状态管理怎么办?)