Repository navigation
v2.1.0
Survive browsers that turn storage off
Some visitors disable storage, so reaching localStorage or sessionStorage throws or returns null. ak.js now exports ifLocalStorage and ifSessionStorage. When storage is turned off, they return an inert stand-in: reads return null, writes do nothing and length is 0.
They only cover storage that is turned off. When storage is on, getItem and setItem still throw like the browser's own methods, so a caller that can hit a real failure (for example a full quota) wraps its own call.
ak.js: session and color-scheme handling use them, so a visitor with storage off gets their first-visit behavior and the default color scheme.scripts/utils/lazyhash.js,blocks/header/header.jsandblocks/schedule/schedule.jsuse them too.tools/keeps native storage and still fails immediately when storage is off.
Taking this into an existing project
Taking scripts/ak.js on its own is safe. lazyhash.js, header.js and schedule.js now import ifLocalStorage from it, so taking any of them without the new ak.js fails with a missing export.