1

Assuming elements in list may be added or removed but element properties stay the same, is it performance improvement to use {#...} instead {!...} ?

In below example, it is decided that title prop is not going to be modified:

<aura:iteration items="{!v.feedItemList}" var="feedItem">
    <h2>{#feedItem.title}</h2>
</aura:iteration>

1 Answer 1

3

Yes, it is a performance benefit to use unbound expressions whenever possible. From the release notes:

Use the {#expression} syntax for unbound expressions when you pass an expression from a parent component to a child component, unless you require bidirectional data binding. Bound expressions with {!expression} create a bidirectional data binding that’s expensive for performance. Bound expressions can also create hard-to-debug errors due to the propagation of data changes through nested components.

In this case, using the unbound expression syntax will result in a shorter rendering cycle. Note that, as you've written in your example code, the items parameter must be a bound expression or the list can't be updated.

3
  • To be honest I don't think this part of documentation is perfectly related to my question. What I am thinking is if part {#feedItem.title} is really rerendered or at least somehow processed internally in other scenarios than if title was modified. In any case it wouldn't be bad practice to put unbound expression. The question that comes from my thoughts is: Is bound expression impacting performance even if unrelated attributes changed? Commented Oct 11, 2017 at 13:21
  • 1
    @Wojciech setting up the bidirectional data takes up more time during the rendering process. Changing the items contents still causes the entire list to rerender, but the cost per item is reduced by using unbound expressions.
    – sfdcfox
    Commented Oct 11, 2017 at 14:12
  • Good to know. Is it something you guessed, tested or you have deep knowledge about framework? Commented Oct 12, 2017 at 8:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .