# dot-dom
**Repository Path**: mirrors_dafrok/dot-dom
## Basic Information
- **Project Name**: dot-dom
- **Description**: .dom is a tiny (511 byte) template engine that uses virtual DOM and some of react principles
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-08
- **Last Updated**: 2026-05-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# .dom [](https://travis-ci.org/wavesoft/dot-dom) [](https://codepen.io/anon/pen/YNdNwv?editors=0010) [](https://gitter.im/wavesoft/dot-dom?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
> A tiny (511 byte) virtual DOM template engine for embedded projects
|
IE / Edge |
Firefox |
Chrome |
Safari |
Opera |
iOS Safari |
Chrome for Android |
| --------- | --------- | --------- | --------- | --------- | --------- | --------- |
| Edge 14+ | 45+ | 49+ | 10+ | 37+ | 10.2+ | 55+
**.dom** borrows some concepts from React.js (such as the re-usable Components and the Virtual DOM) and tries to replicate them with the smallest possible footprint, exploiting the ES6 javascript features.
Why? Because with such library you can create powerful GUIs in tight space environments, such as IoT devices, where saving even an extra byte actually matters!
### Features
* _Tiny by design_ : The library should never exceed the 512 bytes in size. The goal is not to have yet another template engine, but to have as many features as possible in 512 bytes. If a new feature is needed, an other must be sacraficed or the scope must be reduced.
* _Built for the future_ : The library is heavily exploiting the ES6 specifications, meaning that it's **not** supported by older browsers. Currently it's supported by the 70% of the browsers in the market, but expect this to be 90% within the next year.
* _Declarative_ : Describe your HTML DOM in a structured, natural manner, helping you create powerful yet readable user interfaces.
* _Component-Oriented_ : Just like React.js, **.dom** promotes the use of functional components.
* _"Write less" accelerators_ : The library API is designed specifically to have short function names and accelerators, allowing you to describe your views with less code.
## Installation
For minimum footprint, include `dotdom.min.js.gz` (511b) to your project.
```html
```
Alternatively you can just include the minified version of the library directly before your script. Just copy-paste the [minified code](https://raw.githubusercontent.com/wavesoft/dot-dom/master/dotdom.min.js).
## Examples
If you already know React.js, the following examples can help you understand how
the .dom primitives relate to React.
#### 1. Plain DOM
Rendering a very simple DOM structure.
| React | .dom |
|---|---|
ReactDOM.render(
React.createElement('div', null, 'Hello world'),
document.body
);
|
R(
H('div', 'Hello world'),
document.body
)
|
| React | .dom |
|---|---|
function Hello(props) {
return React.createElement(
'div', null, `Hello ${props.toWhat}`
);
}
ReactDOM.render(
React.createElement(
Hello, {toWhat: 'World'}, null
),
document.body
);
|
function Hello(props) {
return H('div', `Hello ${props.toWhat}`);
}
R(
H(Hello, {toWhat: 'World'}),
document.body
)
|
| React | .dom |
|---|---|
class Clickable extends React.Component {
constructor() {
super(...arguments);
this.state = {
clicks: 0
};
}
render() {
const {clicks} = this.state;
return React.createElement(
'button', {
onClick() {
this.setState({clicks: clicks+1})
}
}, `Clicked ${clicks} times`
);
}
}
ReactDOM.render(
React.createElement('div', null,
React.createElement(Clickable, null, null),
React.createElement(Clickable, null, null)
),
document.body
);
|
function Clickable(props, state, setState) {
const {clicks=0} = state;
return H('button',
{
onclick() {
setState({clicks: clicks+1})
}
},
`Clicked ${clicks} times`
);
}
R(
H('div',
H(Clickable),
H(Clickable)
),
document.body
)
|