pelo

⚡️ Lightning fast server-side rendering with tagged template literals

  • 所有者: shuhei/pelo
  • 平台:
  • 许可证:
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

pelo

Lightning fast server-side rendering with tagged template literals

A tiny library that enables lightning fast server-side rendering with hyperx-like libraries such as bel, yo-yo and choo/html. It replaces the tag function of those libraries and just renders string without creating intermediate objects.

Installing

npm install pelo

Usage

ssr.js: Call pelo.replace(moduleId) before you require any view module, bel in this case.

const pelo = require('pelo')
pelo.replace('bel')
const view = require('./view')

const renderedString = view('pelo').toString()

view.js: You don't need to change your view files at all. You can use them for client-side rendering and server-side rendering.

const html = require('bel')

module.exports = function helloView(name) {
  return html`<p>Hello, ${name}</p>`
}

Benchmark

Rendering a simple view 10,000 times:

node benchmark.js
```, tag, time (ms), ----, ---------, pelo, 219.093, bel, 1982.610, ## Motivation

Server-side rendering with modern JavaScript frameworks is slow. In general, they focus on the client-side, and generate virtual/real DOMs for efficient DOM updates from templates. However, this approach is a bit overkill when we focus on server-side rendering. Because the templates already look like HTML, it should be faster if they directly render HTML strings without creating intermediate object representations.

With [`bel`](https://github.com/shama/bel), we can write HTML with tagged template literals and use them to create declarative views on browser. If we can use the same template also for directly generating HTML string on server-side, it will be a huge win.

## Thanks

Thanks [@yoshuawuyts](https://github.com/yoshuawuyts) for lots of advice!

主要指标

概览
名称与所有者shuhei/pelo
主编程语言JavaScript
编程语言JavaScript (语言数: 1)
平台
许可证
所有者活动
创建于2017-04-23 20:59:48
推送于2018-01-27 12:39:31
最后一次提交2018-01-27 13:39:18
发布数6
最新版本名称v0.1.0 (发布于 2018-01-27 13:36:44)
第一版名称v0.0.1 (发布于 2017-04-24 23:51:21)
用户参与
星数147
关注者数3
派生数16
提交数41
已启用问题?
问题数12
打开的问题数4
拉请求数6
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?