# pelo

> Lightning fast server-side rendering with tagged template literals

Latest version **0.1.0** (published 2018-01-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install pelo
pnpm add pelo
yarn add pelo
bun add pelo
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2018-01-27 |
| First published | 2017-04-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 148 |
| Author | Shuhei Kagawa |
| Maintainers | shuhei |

## Links

- npm: https://www.npmjs.com/package/pelo
- Repository: https://github.com/shuhei/pelo
- Issues: https://github.com/shuhei/pelo/issues
- npm.io page: https://npm.io/package/pelo

## Recent versions

- 0.1.0 (latest) — 2018-01-27
- 0.0.0 (beta) — 2017-04-24
- 0.0.5 — 2017-11-04
- 0.0.4 — 2017-10-25
- 0.0.3 — 2017-08-03
- 0.0.2 — 2017-05-21
- 0.0.1 — 2017-04-24

## README

# pelo (work in progress)

Lightning fast server-side rendering with tagged template literals

A tiny library that enables lightning fast server-side rendering with [hyperx](https://github.com/substack/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

```sh
npm install pelo
```

## Usage

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

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

```js
const html = require('bel')

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

## Benchmark

Rendering a simple view 10,000 times:

```js
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!

---
_Source: https://npm.io/package/pelo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
