ryansolid / s-jsx

An alternative JSX renderer for S.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S JSX

This library is a demonstration of the raw performance of S.js when used with the DOM Expressions runtime. This is an experimental approach used mostly for benchmarking and I'd recommend you checkout the official renderer for S.js, Surplus or Solid which are better tested and provide a more comprehensive set of features.

It accomplishes this with using Babel Plugin JSX DOM Expressions. It compiles JSX to DOM statements and wraps expressions in functions that can be called by the library of choice. In this case autorun wrap these expressions ensuring the view stays up to date. Unlike Virtual DOM only the changed nodes are affected and the whole tree is not re-rendered over and over.

To use simply wrap your code in render:

import { render } from 's-jsx';

render(App, document.body);

And include 'babel-plugin-jsx-dom-expressions' in your babelrc, webpack babel loader, or rollup babel plugin.

"plugins": [["jsx-dom-expressions", {moduleName: 's-jsx'}]]

Installation

> npm install s-jsx babel-plugin-jsx-dom-expressions

Alternatively this library supports Tagged Template Literals or HyperScript for non-precompiled environments by installing the companion library and including variants:

import { html } from 's-jsx/html'; // or
import { h } from 's-jsx/h';

There is a small performance overhead of using these runtimes but the performance is still very impressive. Further documentation available at: Lit DOM Expressions and Hyper DOM Expressions.

About

An alternative JSX renderer for S.js

License:MIT License


Languages

Language:JavaScript 94.0%Language:TypeScript 6.0%