Calculating usage of localStorage space

后端 未结 12 1576
悲哀的现实
悲哀的现实 2020-11-27 10:28

I am creating an app using the Bespin editor and HTML5\'s localStorage. It stores all files locally and helps with grammar, uses JSLint and some other parsers for CSS and HT

12条回答
  •  悲哀的现实
    2020-11-27 10:44

    You can use the below line to accurately calculate this value and here is a jsfiddle for illustration of its use

    alert(1024 * 1024 * 5 - escape(encodeURIComponent(JSON.stringify(localStorage))).length);
    

提交回复
热议问题