mithril.js
A JavaScript Framework for Building Brilliant Applications
Mithril.js is a complete JavaScript framework under 9 kilobytes that includes a virtual DOM, router, and networking utilities for building fast single-page web apps with minimal overhead.
Mithril.js is a JavaScript framework for building single-page web applications. A single-page application is a website where navigating between sections does not reload the entire page; instead, JavaScript dynamically updates only the parts of the screen that change, making the experience feel faster and more like a native app.
What sets Mithril apart from larger frameworks is its size: the whole library is under 9 kilobytes when compressed, which means it loads extremely quickly. Despite being small, it includes everything a developer commonly needs: a way to describe the interface using a virtual DOM (a system where you describe what the screen should look like and Mithril figures out the minimum changes needed to update it), a built-in router for handling navigation between different views, and built-in utilities for making network requests to servers. Many other frameworks require separate libraries for routing and networking, adding extra size and configuration.
The framework is used by companies including Vimeo and Nike, and powers the chess platform Lichess. It supports modern versions of Firefox, Edge, Safari, and Chrome without requiring any extra compatibility code.
Installation is simple: you can either include a single script tag in an HTML file to load it from a public content delivery network, or install it via npm (the standard package manager for JavaScript projects). TypeScript type definitions are also available, which helps developers who use TypeScript for its static type checking.
Mithril is suitable for developers who want a framework with a small footprint and low overhead, particularly for projects where bundle size or load time matters.
Where it fits
- Build a single-page web app that navigates between views without reloading the page, using Mithril's built-in router.
- Create a fast-loading interactive UI where bundle size matters, without pulling in a large framework.
- Fetch data from a server API and render it dynamically on screen using Mithril's built-in request utilities.