• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language
    JavaScript
  • Created over 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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, 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 for lots of advice!

More Repositories

1

material-colors

Colors of Google's Material Design made available to coders
JavaScript
272
star
2

babel-angular2-app

A super-simple skeleton Angular 2 app built with Babel and Browserify.
JavaScript
259
star
3

cymbal

Yet another Rust implementation of the Monkey language from "Writing an Interpreter in Go" and "Writing a Compiler in Go"
Rust
81
star
4

babel-plugin-angular2-annotations

A babel transformer plugin for Angular 2 annotations
JavaScript
80
star
5

colortty

🎨 A utility to generate color schemes for alacritty
Rust
68
star
6

Compare

A super-simple mobile app to compare temperatures of yesterday and today.
JavaScript
64
star
7

pixelm

A pixel art editor written in Elm
Elm
37
star
8

todomvc-choo

A TodoMVC app built with choo
JavaScript
37
star
9

Rectify

[WIP] A sample Android application that performs perspective correction
Java
33
star
10

colortape

Colorize test results of tape.
JavaScript
21
star
11

babel-plugin-auto-assign

[DEPRECATED] A babel plugin that automatically assigns constructor parameters to instance properties.
JavaScript
18
star
12

babel-preset-angular2

A Babel preset for angular2
JavaScript
14
star
13

pollen

A DNS polling library that makes Node.js HTTP clients resilient to DNS errors
JavaScript
13
star
14

qiita-notification

A Chrome extension that shows notifications from Qiita.
JavaScript
8
star
15

babel-plugin-null-safe-accessor

[Deprecated] A Babel plugin to provide null safe accessor syntax like Groovy's
JavaScript
8
star
16

dotfiles

🍞 My personal dotfiles that have configurations for Vim, tmux, Alacritty, Git, etc.
Shell
7
star
17

goban.js

a JavaScript implementation of Go board
JavaScript
6
star
18

rolling-window

A rolling time window implementation for hdr-histogram-js
TypeScript
6
star
19

morning_pages

A Morning Pages app for scriptio continua
Go
5
star
20

knowledge

✏️ A heap of TIL
5
star
21

typed-recompose

WIP: Adding type definition to recompose
JavaScript
4
star
22

blurred-cube

JavaScript
4
star
23

date_timezone

An ActiveRecord concern for assigning date string with timezone
Ruby
4
star
24

ynan26

You Need An N26—connects your N26 account to YNAB
Rust
4
star
25

clrs

My humble implementations of algorithms in Introduction to Algorithms a.k.a. CLRS
TypeScript
3
star
26

shuhei.github.com

My personal website built with randomly chosen technologies
JavaScript
3
star
27

gh-pagesify

Publish gh-pages like a breeze
Shell
3
star
28

gulp-quick-start

gulp quick start for web designers inspired by "grunt quick start for web designers" article
JavaScript
3
star
29

48scheme

A small Scheme interpreter based on Write Yourself a Scheme in 48 Hours.
Haskell
3
star
30

react-sample-counter

A sample application that demonstrates React's basic features
JavaScript
2
star
31

okasaki

Solutions to the exercises of Purely Functional Data Structures by Chris Okasaki
Haskell
2
star
32

passport-untappd

Passport strategy for authenticating with Untappd using the OAuth 2.0 API.
JavaScript
2
star
33

tether

JavaScript
2
star
34

babel-plugin-angular2-type-annotation

[Deprecated] An experimental babel transformer plugin for Angular 2 type annotation
JavaScript
2
star
35

rollup-plugin-extract-translation-keys

JavaScript
2
star
36

dymaxion-paint

An entry for GDD 2011 HTML5 Challenge
JavaScript
2
star
37

serial-websocket

JavaScript
2
star
38

accbook

Simple budget manager
Elm
2
star
39

inline-requires-webpack-plugin

PoC for inline requires with Webpack
JavaScript
1
star
40

timecard

Generate event summaries from OS X Calendar app.
Ruby
1
star
41

vim-jours

A simple Vim plugin to write journal.
Vim Script
1
star
42

pub-crawler

Visualize homebrew formulae on your machine
JavaScript
1
star
43

vinotate

JavaScript
1
star
44

tlpi

Code samples from The Linux Programming Interface
C
1
star
45

sicp

My humble solutions to SICP exercises
Scheme
1
star
46

box_intersection

Ruby
1
star
47

blurredCube

C++
1
star
48

jbuilder_inline_partials

WIP: Inline jbuilder partials for better performance
Ruby
1
star
49

jquery-ascensor

Unofficial repository for jQuery Ascensor plugin
JavaScript
1
star
50

gowiki

A super simple wiki implementation in Go
Go
1
star
51

zkviz

Visualization of ZooKeeper nodes
JavaScript
1
star
52

perfume_dev

JavaScript
1
star
53

contrib

A simple web app for people who really care about their github contributions matrices
JavaScript
1
star
54

algo

My humble solutions to programming assignments and related codes of Coursera's "Algorithms: Design and Analysis, Part 1"
JavaScript
1
star
55

todays_beer

Ruby
1
star
56

alc-Dashboard-widget

A dashboard to look up English-Japanse dictionary on Alc
JavaScript
1
star
57

rotating-arcs

Reproduction of RotatingArcs, a Processing example by Marius Watz, with Three.js
JavaScript
1
star
58

webland

Visualize land prices in Japan.
JavaScript
1
star
59

attractors

Strange attractors with some glitch in WebGL
JavaScript
1
star
60

babel-rtts-helper

Helper functions to handle rtts_assert types on babel.
JavaScript
1
star
61

grunt-playground

JavaScript
1
star
62

4628checker

万屋一家シリーズの勤怠管理システム 勤之助 ver.2 の出勤簿をチェックする Chrome 拡張です。
JavaScript
1
star
63

incomplete-image-parser

Incomplete image metadata parsers that I wrote to learn how metadata is stored in image files
JavaScript
1
star