15

I'd like to get a breakdown of how much storage space a web app I'm working on is taking up. More specifically I'm interested in the size of data stored in indexedDB.

I know I can use navigator.storage.estimate() to get a total value, but it shows over 1 mbyte even with an empty db, and I'm interested in knowing the size of indexedDB specifically.

Is there a way to check the size?

user2145184
  • 440
  • 4
  • 15

2 Answers2

16

There is not currently a standard (or even non-standard) API that gives a breakdown of storage usage by type.

  • In Chrome's DevTools, the Application tab provides a breakdown of storage by type; click the "Clear storage" view in the top left and a graph should appear. This is useful for local debugging, but not understanding storage usage "in the wild"

  • There's some discussion about extending navigator.storage.estimate() with this data at https://github.com/whatwg/storage/issues/63

UPDATE: navigator.storage.estimate() now provides a breakdown (in Chrome 75 and later) by storage type.

Joshua Bell
  • 7,727
  • 27
  • 30
  • 2
    I see that there is 15.1 MB used with my indexeddb . It is 172,000 records with key and value pair , the value is json data of several fields. What is interesting is that It says 15.1 MB used out of 16625 MB of storage data in Chrome browser. – Tom Stickel Nov 14 '19 at 05:31
-1

Yes you can make use of the Quota Management API to get these information. this is an experimental feature and currently not supported by EDGE

This site will give you information how Browser support this and can see in real

Example

// Query current usage and availability in Temporary storage:
navigator.storageQuota.queryInfo("temporary").then(
  function(storageInfo) {
    // Continue to initialize local cache using the obtained
    // usage and remaining space (quota - usage) information.
    initializeCache(storageInfo.usage,
                    storageInfo.quota - storageInfo.usage);
  });

More reading is available in W3org

Webber
  • 184
  • 2
  • 13
  • The links from that page go to deprecated posts. Looks like navigator.storageQuota been replaced by navigator.storage, which I mentioned in my question. – user2145184 Nov 03 '18 at 16:44
  • May i know why the negative vote so that i can correct it – Webber Nov 25 '18 at 01:51