Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

monkberry

monkberry411MIT4.0.8

Monkberry is a JavaScript library for building web user interfaces

dom, template, view, ui

readme

Monkberry

npm Build Status

Monkberry is blazingly fast, small 1kb and simple JavaScript library for building web user interfaces.

Example

Monkberry comes with powerfull templating engine, which is compiled to JavaScript.

<ol>
  {% for todos %}
    <li>
      {% if complete %}
        <del>{{ text }}</del>
      {% else %}
        <em>{{ text }}</em>
      {% endif %}
    </li>
  {% endfor %}
</ol>

and then

import Monkberry from 'monkberry';
import Template from 'template.monk';

const view = Monkberry.render(Template, document.body);

view.update({todos: [...]});

Features

  • Small 1kb minified & gzipped
  • Simple, small learning curve
  • Fully tested
  • Precompiled templates
  • Source maps
  • Custom tags
  • Blazingly fast (only necessary dom updates)

Documentation

Documentation available on monkberry.js.org site.

Development

If you want to hack on Monkberry, the first step is to fork the repo.

# Build compiler
npm run build

# Build parser
npm run build:parser

# Watch changes and rebuild
npm run watch

# Start tests server
testem

Plugins

Performance

Benchmarks

Why is Monkberry so fast? Even in comparison with React, Monkberry is 10 times faster, sometimes 100 times faster. It's because Monkberry will do only necessary dom updates, and does it in a completely different way than React does. Monkberry compiles template to plain JavaScript to gain an advantage by using v8 hidden classes and reduce call stack. There is no virtual dom (in general, an react app have to keep 3 virtual doms), for example next template will be generated to JavaScript code which will do only necessary dom updates on state changes.

<div>
  ...
    <h1>{{ title }}</h1>
  ...
</div>

Will be compiled to code like this:

function (state) {
  h1.textContent = state.title;
}

Benchmarks covers a few use cases and compares Monkberry with React and innerHTML. Also, it contains real site code and data.

License

The MIT License (MIT) Copyright © 2016 Medvedev Anton

changelog

CHANGELOG

4.0.7

  • Fixed bug with custom tag importing.
  • Fixed bug in loop with options.

4.0.3

  • A lot of refactoring in compiler and runtime.
  • Improved performance in 1.5 times.
  • New feature: extendable templates.
  • New feature: contexts.
  • New feature: directives.
  • Added support to import anything.
  • Added this expression support.
  • Fixed scope variable updates.
  • Dropped support for wrappers.
  • Dropped support for parsers.
  • Dropped block statements.
  • Refactored filters scope.

3.8.1

  • Fix bug with updating local variable from outer scope.
  • Fix bug with updating custom tags with many attributes.

3.8.0

  • Refactor monkberry-loader hot replacement.
  • Fix monkberry-parser dependency version.

3.7.3

  • Optimized code generation function. 30% less generate code.

3.7.2

  • Improved error messages.

3.7.1

  • Fixed block naming and nested block naming.

3.7.0

  • Added optimization for nested blocks.
  • Added block statement.

3.6.0

  • Added createPool() and getPoolInfo() feature.

3.5.0

  • Added support for HTML entities.

3.4.0

  • Added unsafe feature.

3.3.0

  • Added import feature.
  • Added support.
  • Added spread attributes feature.

3.2.1

  • Fixed code generation for empty expressions.

3.2.0

  • Added global variables feature.

3.1.6

  • Fixed SVG creation.

3.1.5

  • Fixed getElementById() algorithm.

3.1.4

  • Fixed bug in Opera 12.16 in querySelector().

3.1.3

  • Fixed typo in error message.
  • Updated parser version to match synchronized versioning.

3.1.2

  • Fixed very sophisticated bug with local variables.

3.1.1

  • Added createDocument(), and dom() is deprecated.

3.1.0

  • Synchronized versioning begun.

3.0.8

  • Various bug fixes.

3.0.0

  • Improved performance of attributes rendering.
  • New API and new template syntax.
  • Added HTML parser on Jison.
  • Added source maps.
  • Added trimming of whitespaces.
  • Refactored compiler to ES6.

2.0.0

  • Added SVG support.
  • Added key/value options in loops.
  • Added filters.

1.0.0

  • First working prototype.