I have been and always be a big fan of MithrilJS (see my previous posts).
But VanJS changed it all by it's simple API and very tiny size (1.2K)
There is no more reason to use Mithril, at least for me...
Here is a simple Counter in Mithril and VanJS, compare and choose your weapon :-)
import van from "./van.js"
const {button, h1, span, div} = van.tags
// MITHRIL
var count = 0 // added a variable
var Hello = {
view: function() {
return m("main", [
m("h1", {class: "title"}, "Mithril Counter"),
// changed the next line
m("button", {onclick: () => ++count}, count + " clicks"),
])
}
}
m.mount(root, Hello)
//VanJS
// Create a new State object with init value 1
const counter = van.state(1)
let Counter = div (
h1("VanJS Counter ", counter),
button({onclick: () => counter.val++}, span(counter, " clicks"))
)
van.add(document.body, Counter)
Top comments (0)