Tuesday, 15 August 2017

javascript - HTML5 Local Storage vs JSON Object



Are there performance benefits to storing in Local Storage over a JSON object in js? I would assume that it takes (slightly) longer to access, but bogs down the browser (slightly) less.



Any thoughts?


Answer



There is a test case at jsPerf which comes close: http://jsperf.com/localstorage-overhead



As far as I am concerned, I wouldn't bother moving my JS object to localStorage to free up memory. This seems like a overkill to me. Ideally, most of the stuff should be scoped inside functions and there should be as little stuff as possible in the global namespace(something that will live in memory for your app's entire lifetime).




Hope this helps.


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...