Search code examples
javascriptangularjsperformancereactjsmithril.js

Improve Angular performance: change the view to reactjs or Mithril?


I have a performance issues with Angular (as many others). I wish to change only the view layer to either reactjs or Mithril. I found examples of React js (for example http://www.bimeanalytics.com/engineering-blog/you-put-your-react-into-my-angular/), but not of Mithril. Can anyone advice to the pros and cons of using Mithril as an angular view vs Reactjs? Thank you!


Solution

  • I don't think there's an objective answer here, and as a Mithril user I have my biases, but here is what I think.

    In terms of philosophy, Mithril and React are quite similar: you write view functions that describe how your app should look at any given time. In terms of rendering performance, I don't think there's a clear winner. There are links / blog posts that say Mithril is faster than React, and vice versa.

    So instead what I think you should focus on is:

    1) Which API do you prefer? With React you should use JSX lest you have to reverse engineer their documentation. Mithril also just has one lifecycle hook (the view function), whereas React has several (such as shouldComponentUpdate) -- do you need all those hooks?

    2) Community support -- React is the clear winner here, and the fact that there are existing examples of integration with Angular is a win.

    3) Compatibility - DOM redrawing / diffing in React is done when data changes, just like Angular, but Mithril's redraw is centered around user interaction (such as clicks, route changes, ajax requests). You can manually redraw, but that's less desirable. I don't know how well Mithril will fit into an Angular setup.

    Should you decide to use Mithril, I'd encourage you to use the Google group (https://groups.google.com/forum/#!forum/mithriljs) as a resource, or at least report back on your experience.