Getting started

learn-ez.js

Build a working UI and talk to a server in a few lines, without fighting JavaScript's rough edges. ez takes care of JSON, headers and cryptic errors. You still write your own loops, conditions and logic.

<script src="https://tinkr.tech/learn-ez.js"></script> Download

Add the script tag to your page and a global ez object appears. Every command lives under ez.dom , ez.request , ez.store or ez.utils . Here is a small app that uses most of them:

const body = ez.dom.select('body').at(0)
const list = ez.dom.select('#todos').at(0)

const box = ez.dom.create(body, {tag: 'div', class: 'p-4'})
const input = ez.dom.create(box, {tag: 'input', type: 'text', placeholder: 'Add a todo'})
const button = ez.dom.create(box, {tag: 'button', text: 'Add', class: 'btn'})

button.addEventListener('click', async () => {
  const result = await ez.request.post('/api/todos', {title: input.value})
  if (!result.ok) {
    console.log(result.error)
    return
  }
  ez.dom.create(list, {tag: 'li', text: result.body.title})
})