user417669 user417669 - 1 year ago 82
Javascript Question

Estimating the size of a 10,000 character string stored in localStorage (Javascript)

I am building an application that allows for a finite amount of local storage. I am snagging the text from a web-page and storing it in local storage. I am trying to figure out how many of these I will be able to store (roughly) before hitting my max of 5mb.

Any idea how big a 10,000 character string would be stored in localStorage?

Answer Source

I'd just calculate with 20,000 bytes for 10,000 characters. Should be a safe bet for UFT-8 and match what is needed for UTF-16

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download