ember-learn / guides-source

This repository contains the Ember.js Guides
https://guides.emberjs.com/
MIT License
159 stars 487 forks source link

[Disco]: recommending on{event} instead of on-modifier #2009

Open NullVoxPopuli opened 4 months ago

NullVoxPopuli commented 4 months ago

Motivation: https://github.com/krausest/js-framework-benchmark/pull/1608

It's idiomatic to use {{on}} for event listening, and {{on}} is the only way to have conditionally applied / dynamic event listeners, but for performance sensitive situations, we can do less by using the platform, and we don't need any cleanup behavior, so native onclick should be sufficient.

lifeart commented 4 months ago

@NullVoxPopuli I remember some SSR concerns related to it, but can't find related topics.

Some outdated:

  1. https://github.com/ember-fastboot/ember-cli-fastboot/issues/162
  2. https://github.com/glimmerjs/glimmer-vm/pull/1102
  3. https://github.com/glimmerjs/glimmer-vm/pull/549
bertdeblock commented 4 months ago

AFAIK, the {{on}} modifier was introduced as a better alternative to the on* properties => https://github.com/emberjs/rfcs/pull/471/files#diff-a1482043efff1d9e730b71a8ac6b323a1dedf4c0e3ac20f427944ccb1dbce355R38-R57

NullVoxPopuli commented 4 months ago

My research is showing better is debatable. In fact, specifically, situational (4-5 percent render speed improvement of using on*)

lifeart commented 4 months ago

@NullVoxPopuli here is proof on ~10% perf boost if we don't use removeEventListener