Skip to main content

How do you implement lazy loading of modules or components?

Senior JavaScript
Quick Answer Module lazy loading: const { HeavyComponent } = await import('./heavy') รขโ‚ฌโ€ load only when needed. In React: React.lazy(() => import('./Component')) with Suspense. In bundlers, dynamic import() creates a code split point. For images: IntersectionObserver triggers load when entering viewport, or native loading="lazy". Both reduce initial page load and improve Time to Interactive.

Answer

Lazy loading loads resources only when needed using dynamic imports, code-splitting, or IntersectionObserver for assets. Reduces initial page load time and improves performance.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice