1

I have a javascript application and i dont know what is a better practice for loading data. For example, i have a contact table with my contact informations (FirstName, LastName, Addresses, PhoneNumbers, Website etc.). So now i will show these informations and i make two "lists". In the first list, i will show all my contacts but only with the attributes "FirstName" and "LastName" and if i click on a contact, i will show all informations (FirstName, LastName, Addresses, PhoneNumbers, Websites etc.).

Is it better to load the whole informations at a time or load the "detail" informations only if i click on a contact?

2
  • How many? and why are you storing everything in javascript? Commented Apr 17, 2012 at 13:26
  • > 200, i use KnockoutJS to store the data in viewModels Commented Apr 17, 2012 at 13:27

1 Answer 1

2

Depends on the usage and the network, here are some pros and cons of either way.

Load everything at once into JSON, show what is needed/selected:

Pros

  • If data doesn't change much, can be easily cachable
  • No AJAX, very simple
  • After the first load, everything happens "instantly"

Cons

  • Could hurt you if the data slug is large enough

Get Individual Info via AJAX:

Pros

  • Good if data is constantly changing
  • Good if each Contact's data is large enough to warrant a separate ajax call
  • Good if network latency isn't too horrible

Cons

  • Overkill for small datasets
  • Adds Complexity

So if your dataset isn't all that huge, I would go with the simple route. If it is a large or constantly changing dataset, I would go with the AJAX version.

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

1 Comment

If you really want to reduce waiting you could load the rest asyncronously after the page has been initially loaded. This way you will display basic info fast and catch up on the rest before visitor clicks to expand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.