Which is faster in Ionic on a mobile device on-tap or ng-click. To me they seem pretty similar however onClick is much slower.
codepen
<button class="button button-light button-dark" on-tap="onTap()">tap</button>
<button class="button button-light button-dark" ng-click="onClick()">click</button>
The following post reviews Stephen’s Angular performance tips applied through the lens of an Ionic app, Ionifits, a Zenefits-inspired human resources demo app. It showcases various Ionic App Platform technologies, including Ionic Framework, Capacitor, and Ionic Native Enterprise solutions.
Ionic 4 would be faster than Ionic 3 (quite significant improvements were made) and generally every new framework version comes with some form of improvements. But, Ionic 3 already was fast (as was Ionic 2, and even the original Ionic built on AngularJS).
Definition and Usage. The ng-click directive tells AngularJS what to do when an HTML element is clicked.
Ionic Angular apps embrace lazy loading out of the box, so no changes to Ionifits were necessary. New Ionic apps (created using the ionic start command) are pre-configured with lazy loading, and subsequent app pages created using the Ionic CLI’s generate command are automatically configured as lazy loaded modules, too.
Both should be pretty equal, because a tap can only be determined based on how long the touch event occurs. I did something like this below and had the methods console.log when they fired the callback. I see the tap is going first, but click is happening at the same time in my test.
<button class="button" on-tap="onTap()" ng-click="onClick()">Hit me</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With