AngularJS 1 Performance: One-time bindings in expressions

Updated . Posted . Visible to the public.

In addition to the {{ myValue }} two-way binding syntax, since Angular 1.3 there's a one-time binding syntax, prefixing the value or expression with ::, e.g. {{ ::myValue }}, {{ ::myValue >= 42 }} and {{ ::myExpression(value) | someFilter }}.

One-time bound expressions get dropped from the list of watchers as soon as they can be resolved. Performance-wise the impact for this small change is huge, since Angular apparently slowes down with too many watchers registered (Source) Show archive.org snapshot . Wherever values don't change after they've been rendered, this syntax can be safely used.

Last edit
Besprechungs-PC
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2014-10-30 15:50)