0
m("div", {
  onclick: function(e) {
    console.log(e); 
  }, 
}, "Test")

Hello, i would like to know if having an event handler such as the one above creates a new function on Mithril redraw? I want to avoid performance issues.

Carlos
  • 139
  • 2
  • 12

1 Answers1

1

It will be recreated on each redraw. The perf impact is generally negligible.

https://jsperf.com/create-function-vs-reference isn't an exact test, but hopefully provides a rough idea of the difference.

Always profile though! If the function creation is your bottleneck abstracting it out would be an easy fix.

Tivac
  • 2,553
  • 18
  • 21