The beauty of simplicity


Mithril is a modern client-side JavaScript framework for building Single Page Applications. It’s fast, provides routing and XHR utilities out of the box. While being zipped in a file size no more than 8.18 KB gzipped. As an example of how amazing of an achievement that is, the following chart shows Mithril’s size compared to other MVC frameworks.

Sure Mithril might be smaller as compared to other framework but what does that mean for it’s performance. The following is a framework benchmark on a Simple TODO application.

One might ask that is this all smoke and mirrors. How can a framework with just a reduced size perform better than it’s competitors . Well Mithril follows the less-is-more school of thought. It has a substantially smaller,aggressively optimized code base. The rationale is that a small code base is easier to audit and optimize, and ultimately results in less code being run.

Whereas framework such as React have a sophisticated build system that disables various checks and error for production deployments, various browser-specific optimizations. Generally speaking, React’s approach to performance is to engineer relatively complex solutions.


Not another library to learn

Well great news is that you if already know React or other frameworks which follow the flux model of uni-directional data flow with states and components. Then Mithril should be a breeze to learn. The following is a code snippet for simple render.

var root = document.body

m.render(root, [
m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", "A button"),
])
])

To be continued……

Like what you read? Give Mustafa Khan a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.