Which THREE strategies are recommended for improving the performance of Lightning Web Components rendering large lists of data? Choose 3 answers.
Providing a unique, stable `key` attribute on each iterated element directly satisfies the requirement for rendering large lists of data efficiently. The Lightning Web Components framework relies on the `key` value within `for:each` directives to uniquely identify DOM nodes during the virtual DOM reconciliation process. When the underlying array updates, the diffing algorithm uses these stable keys to track item insertions, deletions, and reordering accurately. This mechanism prevents the browser from having to needlessly destroy and recreate entire DOM subtrees, thereby optimising rendering performance and preserving internal component state.
Why this answer
Option B is correct because giving each iterated element a unique, stable key (e.g., the record Id) in for:each loops lets the Lightning Web Components engine's diffing algorithm track items across re-renders and reuse DOM nodes instead of destroying and recreating them, which dramatically reduces rendering work. Option C is correct because pagination, virtual scrolling, or lazy loading limits the number of rows actually rendered in the DOM at any time, so the browser only paints a small window of records rather than the entire dataset, keeping render and layout times low. Option D is correct because getter properties referenced in a template are re-evaluated on every render cycle, so placing heavy computation or data transformation there multiplies the cost across all rows; moving that logic to one-time initialization or cached properties avoids repeated expensive work.
Option A is not recommended because synchronous imperative Apex calls block the client thread and, when invoked inside iterators, can fire one call per row, causing severe latency and governor-limit pressure. Option E is incorrect because rendering all 10,000 records at once in a single flat DOM tree creates an enormous DOM, causing slow initial render, sluggish scrolling, and high memory usage, which is exactly the anti-pattern these strategies are meant to avoid.
Exam trap
The trap is selecting options that seem intuitive but actually harm performance, such as rendering all records at once or using synchronous calls in loops; candidates may not realize the impact on rendering.