How to get total html5 storage size used by current application

Viewed 7830

I need a way to find the total size taken by an application using HTML5 sessionStorage/ localStorage at run time.

I don't want profiler-based approaches.

What I'm currently doing is -

var data = 0;
for(var v in window.sessionStorage){
 data += window.sessionStorage.getItem(v); 
}

console.log(data);//.length to get char length

And then I copy-paste this value into a text-file and check the size.

Ugly and still doesn't help me either. Is there a way (any method) in the HTML5 API's that have this in-built?

Thank you.

2 Answers
Related