Plat-Dev-301 practice question 9 of 10

Refer to the Aura component below: HTML<aura:component><aura:attribute name="contactInfo" type="Object"/><aura:attribute name="showContactInfo"…

Full set: 160 questions

Refer to the Aura component below: HTML

<aura:component>

<aura:attribute name="contactInfo" type="Object"/>

<aura:attribute name="showContactInfo" type="boolean" default="true"/>

<aura:handler name="init" value="{!this}" action="{!c.init}"/>

<aura:if isTrue="{!v.showContactInfo}">

<c:contactInfo value="{!v.contactInfo}"/>

</aura:if>

</aura:component>

A developer receives complaints that the component loads slowly. Which change can the developer

implement to make the component perform faster?

Answer options
A:

A. Move the contents of <c:contactInfo> into the component.


B:

B. Change the type of contactInfo to "Map".


C:

C. Change the default for showContactInfo to "false".

Correct answer
Correct Answer:
C. C. Change the default for showContactInfo to "false".
Explanation

The component's performance issue stems from unconditionally rendering the child component on initial load because showContactInfo defaults to true. Changing the default to false implements lazy loading. The child component and its associated data processing will not be initiated until the showContactInfo attribute is explicitly changed to true, for example, by a user action. This defers the rendering and improves the initial load time of the parent component.

Why Incorrect

A. Moving the contents of the child component into the parent would likely worsen performance by increasing the parent's complexity and initial payload, preventing lazy loading.
B. Changing the attribute type from Object to Map is a data structure change that would not have a significant impact on the component's rendering performance.

References

1. Salesforce Aura Components Developer Guide, "Performance Best Practices for Aura Components", section "Use Lazy Instantiation for Components". (Explicitly recommends using aura:if with a default false condition to defer component creation).

2. Salesforce Aura Components Developer Guide, "Conditionally Displaying Content with aura:if". (Explains how aura:if adds or removes components from the DOM, which is the mechanism for lazy loading).

Scroll to Top