// theme before first paint: saved choice, else dark (function () { var t = localStorage.getItem('mm-theme') || 'dark'; if (t !== 'system') document.documentElement.dataset.theme = t; })();
localStorage is the simplest persistence layer the browser offers, and most developers either underuse it or abuse it. A practical look at when localStorage is the right tool, the gotchas that catch teams in production, and when to upgrade to IndexedDB.