localStorage Category

April 1, 2019

KV Storage

localStorage is…

  • Good! It’s an incredibly easy API to use.
localStorage.setItem('name', 'Chris'); let name = localStorage.getItem('name');
  • Bad! Philip Walton explains why:
  • localStorage is a synchronous API that blocks the main thread, and any time you access it you potentially prevent your page from being interactive.

    Chrome has an idea (here’s the proposal) for reinventing it. Ultimately the API is even simpler:

    import { storage } from 'std:kv-storage';
    storage.set('name', 'Chris');
    storage.get('name');

    But! It’s async, so I can use awaitRead article

    The post KV Storage appeared first on CSS-Tricks.