if (navigator.storage && navigator.storage.persist) {
navigator.storage.persist().then((persistent) => {
if (persistent) {
console.log("Storage will not be cleared except by explicit user action");
} else {
console.log("Storage may be cleared by the UA under storage pressure.");
}
});
}Storage API / notebook
Storage API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
if (navigator.storage && navigator.storage.persist) {
navigator.storage.persisted().then((persistent) => {
if (persistent) {
console.log("Storage will not be cleared except by explicit user action");
} else {
console.log("Storage may be cleared by the UA under storage pressure.");
}
});
}navigator.storage.estimate().then((estimate) => {
// estimate.quota is the estimated quota
// estimate.usage is the estimated number of bytes used
});