What is Mithril.js?
Much like React, Mithril makes use of a virtual DOM to draw and re-draw the page as users interact with it. It’s much more efficient recreating vnodes on the render cycle than to modify the DOM directly. Mithril uses a sophisticated and highly optimized virtual DOM diffing algorithm to minimize the amount of DOM updates, ensuring fast updates to the page as you go.
Why use Mithril.js?
By now you’re probably wondering why you would use Mithril over the above-mentioned frameworks. Well, Mithril is tiny. Smaller than 10kb gzipped out of the box. This means that the user can load it much faster than more bloated front-end frameworks. When it comes to websites, speed is a huge factor.
Don’t be fooled by its small size, Mithril also includes everything you need to create meaningful web-applications like XHR, routing and state management out of the box. There are many great tools out there to manage those aspects in SPAs and you might have your favourites, but with Mithril that’s not necessary. As they put it: No extra libraries, no magic.
What are the drawbacks?
As with any tool, Mithril isn’t perfect. If you’re reading this post, there’s a good chance that you’re a developer. And, as a developer, you’d understand the important relationship that we developers have with Stack Overflow. Herein lies Mithril’s biggest drawback: If you run into problems with Mithril, you’re unlikely to find a solution to your problem on Stack Overflow. It’s just not popular enough.
However, having said that, Mithril’s documentation is pretty good. There’s also an active Gitter community dedicated to Mithril where you can ask questions if you need help. The only downside is that you might actually have to interact with people and that’s not traditionally a developer strong suit, eek!
If you didn’t know about Mithril.js before, I hope I’ve enticed you to check it out. Although nowadays I’m a React developer, Mithril was my first framework and it holds a dear place in my heart.
Do you like to use a lesser-known framework or tool? Let me know what it is on Twitter. I’m always looking to expand my repertoire and these hidden gems deserve some love too!