Bird
0
0

You want to lazy load two standalone components, AdminComponent and UserComponent, under routes '/admin' and '/user'. Which is the best way to configure the routes to optimize initial load time?

hard📝 Application Q15 of 15
Angular - Standalone Components
You want to lazy load two standalone components, AdminComponent and UserComponent, under routes '/admin' and '/user'. Which is the best way to configure the routes to optimize initial load time?
AImport both components eagerly and assign them to routes directly
BUse <code>loadChildren</code> to lazy load a module containing both components
CUse <code>loadComponent</code> with dynamic imports for both routes separately
DCombine both components into one and lazy load that single component
Step-by-Step Solution
Solution:
  1. Step 1: Understand lazy loading standalone components

    Using loadComponent with dynamic imports allows each component to load only when its route is visited, reducing initial load.
  2. Step 2: Compare options for multiple components

    Use loadComponent with dynamic imports for both routes separately loads each component lazily and separately, optimizing load time better than eager loading or bundling.
  3. Final Answer:

    Use loadComponent with dynamic imports for both routes separately -> Option C
  4. Quick Check:

    Separate loadComponent calls = best lazy loading [OK]
Quick Trick: Lazy load each standalone component separately with loadComponent [OK]
Common Mistakes:
  • Eagerly importing components defeats lazy loading
  • Using loadChildren for standalone components unnecessarily
  • Combining components increases initial load size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes