Thursday, 12 May 2022

Clearing local storage with a BookMarklet

I'm doing a fair bit with localStorage at the minute; and I need to clear it out regularly. Opening the chrome://settings can get boring real quick, so I spent a happy 5 minutes researching the subject and clocked that a Bookmarklet would work a treat; here it is Clear Local Storage, feel free to use it. Here's the JS should you need to adapt it for your purposes:

javascript:(() => {
  localStorage.clear();
  location.reload();
  console.info('Local Storage Cleared');
})();

Edit

I realised that I needed to refresh the page for the cleared cache to be evident, I've added a location.reload() to do just that.