What are the best practices to improve LWC performance?
Answer
- Prefer Lightning Data Service and cacheable
@wirecalls to avoid redundant server trips. - Fetch only needed fields and records; paginate large lists.
- Use
lwc:ifto avoid rendering hidden content, and lazy-load heavy children. - Provide stable keys in
for:eachfor efficient diffing. - Avoid heavy logic in getters (they run on each render) and avoid DOM manipulation in
renderedCallback. - Debounce user input handlers (e.g. search).
- Don't mutate reactive properties unnecessarily to prevent extra re-renders.
- Load third-party scripts once and bundle assets as static resources.
- Clean up listeners and subscriptions in
disconnectedCallback.
lwcperformancebest-practices