3 ms·
I know this article only uses a simple example here, but it shows a hint of a pattern that angular tries to keep away from the JS, the template generation - gen
by Bahamut 13y ago
I know this article only uses a simple example here, but it shows a hint of a pattern that angular tries to keep away from the JS, the template generation - generating the table children in the script sounds like a cumbersome pattern.
Otherwise, I think it's well known by heavy angular users that some of the built-in angular directives are not necessarily the most efficient - building custom versions of directives like ng-repeat has been the current solution to squeeze out performance in edge cases, although it's unfortunate no one has decided on open sourcing such yet.
One thing I am confident about is when Angular 2.0 hits, things should improve immensely - the whole framework is moving towards modularity so you could presumably swap out the template engine for React, or perhaps the revamp of templating in Angular will make it more competitive performance-wise.
- GamblersFallacy 13y agoYou don't have to wait for Angular 2.0, the author of the article just didn't know the "track by" feature of ng-repeat can be used to optimize performance of rendering big arrays (and to be fair, the docs don't mention the trick explicitly). Here is the same demo, as in the article, with just 'track by $index" added to ng-repeat. As you can see, to the human eye, its just as responsive as the reactjs example. http://plnkr.co/edit/PHzYFa9N4RkxcDzZMcHk?p=preview http://plnkr.co/edit/PHzYFa9N4RkxcDzZMcHk?p=preview
- jasim 13y agoThe `track by` feature alone wouldn't solve Angular performance problems if you are rendering a large dynamic table. Every `ng-*` and text interpolation using `{{ }}` will add one binding per usage. This can add up quite fast and easily cross the sweet spot of 2000 bindings per page (http://stackoverflow.com/questions/9682092/databinding-in-angularjs http://stackoverflow.com/questions/9682092/databinding-in-an...). Large grids are not an ideal use case for Angular, and I like the approach of using React/Mustache or even direct DOM manipulation inside an Angular application when performance is critical.
- GamblersFallacy 13y agoI've build a large custom dynamic table for a real-time datamining web app, didn't have any performance issues because i used 'track by'. The 2000 sweet spot comment from SO was based on angular 1.0.1, which didn't have 'track by' & is approx 1/10 the speed of angular now. Look @ the updated jsperf digest test, from the SO answer, for angular 1.0.1 vs 1.2.14 http://jsperf.com/angularjs-digest/37 http://jsperf.com/angularjs-digest/37