vendix-frontend-lazy-routing

Implement always lazy-loaded Angular routes using loadChildren or loadComponent.

5|Updated Aug 23, 2025
One-click install
npx skills add https://github.com/Rzyfront/Vendix --skill vendix-frontend-lazy-routing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vendix-frontend-lazy-routing
Source: https://github.com/Rzyfront/Vendix/tree/main/skills/vendix-frontend-lazy-routing
Command: npx skills add https://github.com/Rzyfront/Vendix --skill vendix-frontend-lazy-routing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables frontend teams to implement a consistent pattern for always lazy-loaded routes in Angular applications, reducing initial bundle size and improving perceived performance.

Core Features & Use Cases

  • Lazy load standalone components using loadComponent to create on-demand UI pages.
  • Lazy load feature modules using loadChildren for routes with child routes.
  • Real-world example: add a new admin settings route that is loaded only when accessed, avoiding unnecessary code in the initial bundle.

Quick Start

Identify the active parent routes file (for example store_admin.routes.ts) and ensure you do not statically import the target component. Add a route object that uses loadComponent or loadChildren to lazy-load the module or component. Build and run the app, then navigate to the new route and verify that a separate chunk is generated and loaded on demand.

Frequently Asked Questions about vendix-frontend-lazy-routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure lazy-loaded routes for Angular standalone components?

To configure lazy-loaded routes for Angular standalone components, use the loadComponent property in your route configuration object instead of a static import. This ensures the component code is split into a separate chunk and loaded on demand when the route is accessed.

What is the difference between loadChildren and loadComponent in Angular routing?

The difference is that loadComponent lazy-loads a single standalone component, while loadChildren lazy-loads an entire feature module with child routes. Both patterns enforce code-splitting to reduce initial bundle size, but loadComponent is used for individual pages and loadChildren for nested route trees.

How do I verify code-splitting and chunk generation for lazy-loaded Angular routes?

To verify code-splitting and chunk generation, build your Angular application and navigate to the lazy-loaded route. Check the network tab or build output to confirm a separate JavaScript chunk is generated and fetched on demand, ensuring the target code is absent from the initial bundle.

Why should I avoid static imports in Angular route configurations?

You should avoid static imports in Angular route configurations because they bundle the component or module code into the initial payload. Using dynamic loadComponent or loadChildren patterns keeps feature code out of the main bundle, optimizing initial load times and perceived application performance.

Can I use loadChildren for routes with child modules in large Angular feature sets?

Yes, you can use loadChildren for routes with child modules in large Angular feature sets. This pattern is specifically designed to lazy-load feature modules containing nested child routes, ensuring that large feature sets are code-split and loaded only when their specific route is accessed.

Does lazy-loading Angular routes work for both standalone components and child modules?

Yes, lazy-loading Angular routes works for both standalone components and child modules. You use loadComponent for individual standalone components and loadChildren for feature modules with child routes, enforcing code-splitting across both patterns to reduce initial bundle size.