Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Joe Bruno
Joe Bruno
35,909 Points

Local Storage, Global Object, vs Parse API: Speed?

Hello,

I need some advice. I am building a JavaScript shopping cart utilizing Parse.com's API as a backend. I have about 50 products that can be purchased (returned as JavaScript Promises / JSON objects from Parse). I need to query all 50 of these items at multiple points to get information from them for calculations, altering quantities in cart, displaying info in the main view, etc - all sorts of things from both the client and admins side of things.

With regard to speed, would it be fastest to download all 50 at once into the browsers Local Storage and then do all of my queries, calculations, and displays from the data stored there in Local Storage or would it be best and fastest to re-query Parse.com's API directly if I need all or pieces of that data? I guess I am more wondering what the "best practice" would be for something like this, taking into account the limitations of mobile browsers and such: Local Storage vs. Third-Party API. The data returned from Parse is "text" only (strings, objects, arrays, ints, etc): titles, prices, descriptions, tags, categories. No images or media are returned (its JSON).

Another option is to basically store the data in a Javascript object that gets moved around, but I would think that would be slowest?

Any advice or wise words?

Thanks!

Joe