Reputation: 6998
I'm not really sure how to word this so it's making it hard to search but if I have a big application and each component is in it's own js file, then it doesn't make sense to load ALL component files in index.html. The user might never even see a large number of these components as they are navigating through the app.
So the question would be, how can we load components as they are needed in a view that houses them vs all at once?
In a perfect world, as a page is routed it would know the components on the view and know if it's already registered that component and if not, go get the js file to do so and register it automatically for us before running the view. This would require some kind of configuration that says this string component name is this js file on the server.
Does anything like this exist?
Upvotes: 0
Views: 22
Reputation: 6998
Looks like it's called lazy loading of scripts. There seems to be a really easy angular module for this!
Very cool and close to what I was hoping for. Ideally I'd love for config of components and then dynamic loading of components when the view uses then but this is close enough. Perhaps I can enhance this to pre-read the view html looking for components that aren't registered with angular already and then search the config to get them if not.
Upvotes: 1