Enabling Support for Lazy Loading
To get our server-side rendering working correctly, we need to make sure that we add the ModuleMapLoaderModule
. This is a third-party module that is needed to make Angular Universal apps work with lazy loading.
In software development, we talk about lazy loading if we defer loading a certain object or piece of code to the point where we need it. In Angular specifically, this is done by defining certain routes to be loaded at the moment they are requested. The Angular build process will use code splitting to build lazy-loaded parts of the application in separate files. When the user then navigates to this part of the application, the browser will download that file and execute it.
The benefit of this approach is that the initial download size is smaller, and that a user does not have to download parts of the application that are not being used. This decreases the initial loading time of the application and potentially saves network bandwidth.
...