LWCBeginnerimperativeperformancelds
Load imperative Apex on user action not connectedCallback for record pages
Real World Scenario
Every record page load fires five imperative Apex calls from connectedCallback even when user never opens tabs.
Expected Answer
• Defer imperative load to tab activate or section expand event
• Wire critical path data; imperative for on-demand heavy aggregates
• Track loadedTabs Set preventing duplicate fetch on re-expand
• connectedCallback only wire adapters and lightweight init
• Measure record page TTI before after deferral optimization
• Loading placeholder in deferred section not page-level spinner
• Prefetch on hover optional for likely next tab advanced UX
Follow-Up Questions & Answers
Click to expand — each follow-up includes a direct, interview-ready answer
Direct answer: Defer imperative load to tab activate or section expand event Also consider: Wire critical path data; imperative for on-demand heavy aggregates In practice: Track loadedTabs Set preventing duplicate fetch on re-expand Keep the solution simple and well-documented for the team.
Architect Perspective
connectedCallback Apex spam degrades every record page—lazy load is default for heavy reads.