is it better to store one big JSON object in local storage and append into it other data or use multiple small objects with datas in it? I would like to use it as history storage for any some application (so I think 5MB is enough).
Thanks
is it better to store one big JSON object in local storage and append
Share
It really depends on the way you want to access your data:
If you want to access small parts of your data once in a while, you should put it into small objects. I did a couple of performance test a while ago and found the lookup of on objects in a localStorage filled with a lot of objects quit fast. If you use small objects, you might use less memory because you don’t have to read and parse a big json object.
On the other side, keep in mind that reading localStorage is a blocking function. So if you need to iterate over the object, i might block your whole browser. In that case, it might be better to save the data in a huge chunck and read it at once.