WARNING: This documentation is for an old version of mithril! Please see the current docs for more accurate info.

Mithril

A Javascript Framework for Building Brilliant Applications

Guide Download v0.1

Light-weight

  • Only 3kb gzipped, no dependencies
  • Small API, small learning curve

Robust

  • Safe-by-default templates
  • Hierarchical MVC via components

Fast

  • Virtual DOM diffing and compilable templates
  • Intelligent auto-redrawing system

Sample code

//namespace
var app = {};

//model
app.PageList = function() {
	return m.request({method: "GET", url: "pages.json"});
};

//controller
app.controller = function() {
	this.pages = app.PageList();
};

//view
app.view = function(ctrl) {
	return ctrl.pages().map(function(page) {
		return m("a", {href: page.url}, page.title);
	});
};

//initialize
m.module(document.getElementById("example"), app);

Output

Performance

To run the execution time tests below, click on their respective links, run the profiler from your desired browser's developer tools and measure the running time of a page refresh. (Lower is better)

Loading

Mithril 0.28ms
jQuery 13.11ms
Backbone 18.54ms
Angular 7.49ms

Rendering

Mithril 9.44ms (uncompiled)
jQuery 40.27ms
Backbone 23.05ms
Angular 118.63ms

Safety

Mithril templates are safe by default, i.e. you can't unintentionally create security holes.

To run the tests for each framework, click on the respective links. If you see an alert box, ensuring security with that framework is more work for you.

Test Summary

Mithril (pass) ✓
jQuery (fail) ✗
Backbone (fail) ✗
Angular (pass) ✓

Guide

Build a simple app, learn the ropes

Read Guide

API

Docs and code samples for your reference

Read Docs