4 ms·
I'm using Mithril on my current project and it includes everything you need in less than 10kB gzipped (vdom, components, router, http client). Another huge ben
by pier25 7y ago
I'm using Mithril on my current project and it includes everything you need in less than 10kB gzipped (vdom, components, router, http client).
Another huge benefit is that it simplifies you application code immensely. Your store and models are simply vanilla JS since Mithril doesn't have reactivity, observables, etc. Mithril will simply redraw all the vdom whenever a user event happens or when its router/http client do something. You can also call m.redraw() if you need the UI to update if you for example receive something from a web socket.
Obviously with this approach the performance cannot be as good as something like Svelte or Inferno, but it's significantly faster than React.
https://krausest.github.io/js-framework-benchmark/current.html https://krausest.github.io/js-framework-benchmark/current.ht...
Personally I use it with JSX since I can't stand the hyperscript notation.
It's certainly not for everyone and all use cases but I think it's totally valid for a good portion of front end work if you can handle a double edged knife.
- chocolatkey 7y agoFor people like me who like the hyperscript syntax, or have to use it, I've found this site very useful for converting existing HTML templates quicker https://arthurclemens.github.io/mithril-template-converter/index.html https://arthurclemens.github.io/mithril-template-converter/i...
- baddox 7y agoUnless there's more to the story than the redraw methods you described, I would suspect that this approach would not be significantly faster than React if your React components correctly use shouldComponentUpdate and React.memo.
- jahewson 7y agowill simply redraw all the vdom whenever a user event happens > that’s going to be painful when I want to filter a live search result page with more than a just few results.
- wruza 7y agoVdom is not dom. Mithril maintains a previous copy of vnodes (pojo) and only patches corresponding divs when new vnodes differ. Comparing and disposing pojo is cheap. Producing vnodes cheap too, unless you do heavy calculations at render, but that’s true for any framework.
- pier25 7y agoThe vdom is not the dom. I'm using it right now with a gallery of about 2000 items with filtering and search. No problem on an i5 desktop.
- Aeolun 7y agoHave you tried in IE11? I think that’s the true test of speed for any webapp now.
- ____hacker____ 7y agoWhy would you do that in 2020?
- ezramorse 7y agoAwesome until you look around and notice you’ve fallen into a pit of despair (tech debt) and have no ecosystem to leverage your way out of it or people you can hire that want anything to do with it :) There needs to be concerns beyond pure speed and package size to dictate tools. Sometimes real world practical constraints must be considered
- jnwatson 7y agoYou’re saying people don’t want to work on vanilla JavaScript? Really?
- ezramorse 7y agoI’m saying check Mithril npm packages vs react/vue packages, contributed by the people who wanted to work with each framework. Some ecosystems have more work to pull from, more people active and experienced, and more established patterns & tools.
- pier25 7y agoYou don't need much else besides Mithril and maybe a css library. As for hiring I agree somewhat but anyone with a couple of years of front end experience should be able to pick it up in a matter of hours.
- deleted 7y ago[deleted]
- brlewis 7y ago> you’ve fallen into a pit of despair (tech debt) and have no ecosystem to leverage your way out of it or people you can hire that want anything to do with it It sounds like you're saying that the way out of tech debt is to install more 3rd-party packages and/or hire more people, I hope you meant something else. I use and recommend React at work because of the hiring thing, but for my own personal projects I stick with Mithril. With JSX it's not hard to switch back and forth between the two, at least with TypeScript there to tell me when I accidentally use HTML in my React JSX, e.g. the class attribute when React wants the className property. (With Mithril you use attributes that map exactly to HTML attributes)
- voltagex_ 7y ago>The benchmark was run on a Razer Blade 15 Advanced (i7-8750H, 32 GB RAM, Ubuntu 19.10 (Linux 5.3.0-24, mitigations=off), Chrome 79.0.3945.79 (64-bit)) i.e. one of the fastest consumer machines around. I wonder how much the web would be better if more people targetted a $300 laptop instead of a $3000 one. Or probably a $30 Android instead of a $1000 iPhone.
- pier25 7y agoYeah but the point is comparing the frameworks among themselves.
- rimliu 7y agoAnd then there is https://svelte.dev/ https://svelte.dev/ which does not even have vdom. And Rich Harris (the author) has pretty strong opinions about it. Check out his talks on YouTube, worth it.
- ezramorse 7y agoSapper is worth a look for SSR folks https://sapper.svelte.dev/ https://sapper.svelte.dev/
- pier25 7y agoSvelte has many great things going on. I have dabbled with it and will probably use it more seriously on my next project. My only annoyance is that I've grown accustomed to making micro components with React, Inferno, and Mithril on the same file. Stuff like buttons and such. With Svelte (and Vue when using SFC) you need to create each component in its own file which becomes tedious for more complicated views.
- loustak 7y agoGlad I see someone mentioning Mitrhil. I love it and start to have real world use cases such as Lichess.