You can use Dynamic component loader service
- Which respect component module, providers, context
Use "defer" strategies
- Wrap "heavy" libraries with async conditions
- Meaning, wrap your function that need third party libraries in a Promise or Observable and use RxJS to defer the execution. Only executed when subscribed to.
Do lazy loading on router resolver level.
- Useful if route params specify features of the rendered view
Lazy loading is most effective with proper caching
What is not essential and could be loaded lazily, should be loaded lazily
Preload/Prefetch code that is likely to be used
Write three-shakable code
Observe your bundle size before you run into troubles
Use Bundle Wizard: https://github.com/aholachek/bundle-wizard