0

The problem:

AngularJS forces to split view from model and it's good. But we're experiencing the following downsides because of it: When a user loads our page a browser makes not 1, but 2 requests:

  1. First it loads view template (the first request)
  2. Then Angular services load data from a server (the second request)

And we have a bit slower load page speed.

The question:

Is it possible after first page loading load view with populated data and only then get data from a server when something must be changed on the page?

I tried to find something regarding it, but didn't find anything.

1
  • How do you load the data from server and pass it to the view? Some code will help Commented May 27, 2015 at 14:30

2 Answers 2

1

You will have a lot more request as you have to load the Javascript and CSS libraries as well.

You can store your initial data in a service or the rootscope and just update the data when you need it. What's exactly your problem here?

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

Comments

1

The modular approach would be to break all the different components of the page that consume data into separate data requests, so that the interface can load in progressively as different data requests complete.

Additionally, you can load initial data, but then make some predictions on what the user will do next and lazy load additional data in the background.

Finally, you could store the previously loaded data in local storage (lots of modules out there you can utilize) so that it's pulled instantly upon the user's next visit. You would want to want to also add some sort of timestamp comparison on data in storage and on server to see if it has been updated.

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.