1

I've created a separated module for each page of my AngularJS app.

Is it better to load the scripts when needed (e.g: use ui-router resolve and oclazyload to load the invoice_module for the invoices page).

Or simply just combine all of the app files into one and load them all at once?

1 Answer 1

2

It depends largely on how you expect users to move through your app.

If the typical use case is to touch many pages in a session, then it might be a good idea to combine all the files -- this will result in a longer initial load, but subsequent transitions will be near-instant.

On the other hand, if you expect users to only hit one or two pages of the app in a typical visit (i.e. the pages are somehow "separate" from each other) then lazy loading could be to your advantage.

Personally, I always concat/minify into one package. Unless your modules are huge (10s/100s of KB huge) or there are sufficient metrics to back up a better user experience with lazy loading, it's not really worth the effort to implement it. And also, your users are already loading Angular which is itself pretty big anyway.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.