by Brandon Konkle
It was created by Jordan Walke, inspired by Facebook's XHP project which was in turn inspired by E4X. Both projects allow you to embed XML within other languages.
Pete Hunt wanted to use it for Instagram, so he refactored it into an open source package.
They independently came to the idea of a virtual DOM. Developer Rich Harris of The Guardian blogged:
I distinctly remember reading the post on Hacker News and thinking 'well I may as well give up' – so many of Ractive's ideas, which a day earlier had seemed entirely novel, had already been implemented by a team of engineers with the might of Facebook behind them.
Ractive parses your Mustache templates into an intermediate representation of the DOM.
construct, config, init, render, complete, change, update, unrender, teardown, insert, detach
By default, a Ractive instance will update its internal model based on user input, if you have <input>, <textarea> or <select> elements.
This is similar to React's optional "controlled components".
Ractive components expose their data as observables. You can even use wildcards in the keypath.
Turns this:
Into this:
Which results in a slight performance improvement.
Elm includes helpers to make it easier to describe the DOM.
The DOM is converted into a virtual-dom tree.
Since all Elm functions are pure, the same input is guaranteed to result in the same output. This allows the diff calculation to skip over DOM nodes with arguments that haven't changed.
Instead of calling the todoList function on every frame, this example checks to see if state.tasks has changed since last frame. If not, todoList is skipped.
(This is equivalent to comparing props in React's componentShouldUpdate method.)
It's tiny! ~6kb
The scope is intentionally limited:
They have functions & properties on them. They don't store any state on themselves or use this anywhere.
Use them just like React components, complete with JSX:
It analyzes Handlebars templates at compile time, identifying static areas that don't change and dynamic areas that do. Virtual DOM diffing is done against the dynamic areas only.
When re-rendering, Glimmer walks the tree and flushes the streams. If the primitive value produced by the stream has not changed, it does nothing.
Like other virtual DOM libraries, Glimmer works by walking the tree, looking for dirty nodes, and revalidating any dirty nodes it finds.
With Glimmer, only the dynamic portions of the DOM are marked dirty and revalidated.