Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Loading #130

Open
MacrofonoEstudio opened this issue Oct 19, 2016 · 10 comments
Open

Lazy Loading #130

MacrofonoEstudio opened this issue Oct 19, 2016 · 10 comments

Comments

@MacrofonoEstudio
Copy link

Hi there!

We are starting a big app (+400screens) and we are thinking to follow your style guide. We have a main doubt; can’t figure out how to implement Lazy Loading when the route is defined in the routed component itself.

Is it possible to implemented Lazy Loading in this kind of apps? Do we have to load all the app components at the beginning?

Thank you for your great work!

Aleix

@george3447
Copy link

@MacrofonoEstudio
Copy link
Author

MacrofonoEstudio commented Nov 21, 2016

Thank you for your answer @george3447, cool project 👍

I have started to use ui-router 1.0 too, but without WeckPack. Something like this:

$stateProvider
                .state("transfers", <ng.ui.IState> {
                    url: "/transfers",
                    lazyLoad: (transition) =>
                            transition
                                .injector()
                                .get("$ocLazyLoad")
                                .load(["app/js/components/view/section/transfers/transfers.module.min.js"]),
                    
                });

@george3447
Copy link

@MacrofonoEstudio thanks for sharing. I am pretty much curious to know which build system you are using, and how you split the code module wise?

@mattbrunetti
Copy link

@MacrofonoEstudio I'm also very curious to know which build system you're using and how (or whether) you split the code into bundles, since that would seem to be a challenge implementing with lazy loading..

(Please say you're using browserify and the factor-bundle plugin! 😄 )

Anyways, Lazy Loading is a must-have for our application, since our it's expected to grow to an unbounded number of screens. Well factored bundles that reduce the number of required HTTP requests is less of a necessity. Nonetheless I would like to have both, and I'll be working on this issue.

@toddmotto If we wanted to contribute Lazy Loading (with well-factored code bundles) to your style guide, would it be best to start with a PR here? Or in angular-1-5-components-app? Or is Lazy Loading out-of-scope for these repositories?

Sorry for my lack of background-knowledge and if I've confused anything here. I've new to AngularJS, but have lots of experience with ES6, module loaders, build systems, etc. @george3447 Did I understand correctly what you are curious about?

@toddmotto
Copy link
Owner

Hey Matt. I think a performance section is definitely warranted - not sure if it should be more "resources" focused or showing code examples - I think a list of resources keeps the guide more focused to point to external resources with code demos etc. Lay it out to play it out... as the saying goes 🎱

@MacrofonoEstudio
Copy link
Author

MacrofonoEstudio commented Nov 28, 2016

Hi @george3447 @mattbrunetti ,
We started without bundeling because of the lack of knowlege . Now we are starting with Webpack.
Any good resources about it to recommend?
@mattbrunetti It would be nice a post about it!
Thanks!

@mattbrunetti
Copy link

@MacrofonoEstudio There certainly are a some resources on the subject to go through. Not sure which ones are good though lol

This demo is linked to from the ocLazyLoad docs site - https://github.com/ay13/webpack-angular-oclazyload

Here's another demo and a blog post I'd look into if I was going the webpack way.

@george3447 Any resources to add?

I think I would rather go the gulp+browserify way though, as it takes a more modular approach and thus has a healthier ecosystem of plugins and is more flexible, at the expense of sometimes requiring more setup. See comments on this gist for a good debate.

In our own implementation we will basically be trying to work lazy-loading into a setup like angularjs-gulp-browserify-boilerplate.

@mattbrunetti
Copy link

@toddmotto Definitely with you on the whole references to resources keeping it focused thing. I think inline code samples should only be used when necessary, to tie the references together.

@george3447
Copy link

@mattbrunetti no other resources that I am aware of. I have used that exact same blog post that you have pointed to implement lazy loading.

@ViieeS
Copy link

ViieeS commented Mar 5, 2018

since AngularJS v1.6.7 you can use native method $injector.loadNewModules for lazy-loading
https://github.com/angular/angular.js/blob/master/CHANGELOG.md#new-features-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants