W3cubDocs

/DOM

StorageManager.estimate

The estimate() method of the StorageManager interface asks the Storage Manager to obtain quota and usage information for the current origin. This method operates asynchronously, so it returns a Promise which resolves once the information is available. The promise's fulfillment handler receives as an input a StorageEstimate with the usage and quota data.

Syntax

var estimatePromise = StorageManager.estimate();

Parameters

None.

Return value

A Promise that resolves to an object which conforms to the StorageEstimate dictionary. This dictionary contains estimates of how much space is available to the origin or app (in StorageEstimate.quota, as well as how much is currently used (in StorageEstimate.usage). These are not exact numbers; between compression, deduplication, and obfuscation for security reasons, they will not be precise.

You may find that the quota varies from app to app based on factors such as the frequency with which the user visits it, commonly-known site popularity data, and so forth.

Example

In this example, we obtain the usage estimates and present the percentage of storage capacity currently used to the user.

HTML content

<p>
  You're currently using about <span id="percent">
  </span>% of your available storage.
</p>

JavaScript content

navigator.storage.estimate().then(estimate => {
  document.getElementById("percent").innerHTML =
          (estimate.usage/estimate.quota).toFixed(2);
});

Result

Specifications

Specification Status Comment
Storage
The definition of 'estimate()' in that specification.
Living Standard Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 55.0 51 (51) ? 42 ?
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 55.0 51 (51) ? ? 42 ? 55.0

See also

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/StorageManager/estimate