Skip to content

Part II — Browser APIs ​

Six chapters on what the browser gives you before any framework is involved. They cover where state can live, how to keep work off the main thread, how to keep working with no network, and how to speak the user's language. Frameworks deliberately leave most of this to you. The consequences are yours: security, stale data, a broken layout in Arabic.

The through-line is that every one of these APIs has a wrong answer that often ships to production. Browser storage is not a database with a smaller quota. A service worker is not a cache you can purge. A translation file is not internationalisation. Each chapter names the wrong answer first.

Chapters ​

#ChapterWhat it answers
01Web Storage and IndexedDBWhich store, when IndexedDB earns its cost, and why none holds a token?
02Cookies and SameSiteWhich attributes stop a cookie being read or replayed?
03The Observer APIsHow do you stop asking the browser something sixty times a second?
04Web Workers and the Main ThreadWhat can move off the thread that handles input, and what does it cost?
05Service Workers, Caching and OfflineHow do you update a worker without stranding a tab, and which strategy does each request get?
06Internationalisation and the Intl APIsHow do you ship another language, plural rules and right-to-left without a rewrite?

What Interviewers Probe For ​

The senior signal for this part is reaches for the platform before reaching for a library. For these APIs specifically:

  • Where does the access token go? It is the most common browser-storage question in a senior loop, and it has a real answer. Use an HttpOnly cookie, because an XSS can read anything JavaScript can read.
  • Do you know what SameSite=Lax actually blocks? Cross-site POSTs, not top-level GET navigations. Treating it as a complete CSRF defence is a common and expensive mistake.
  • What is the origin boundary? Storage is partitioned by scheme, host and port. Most "the data disappeared" bugs are this, or eviction under storage pressure.
  • How does a service worker update? A fix that "did not ship" is almost always a new worker stuck in waiting. Naming the kill switch unprompted is a strong signal.
  • Is count === 1 enough? It is wrong in most languages. The senior answer asks the locale, through Intl, and puts the locale in the URL.

Reading Order ​

Read 01 and 02 first and together. They are the two halves of "where does state live in the browser". The rest are independent. 05 reads best after 01, because the offline write queue lives in IndexedDB.

Interview sprint: 01 → 02 → 05. The token question, the cookie-attributes question and the service worker update question are the three that actually get asked. Read 06 if the product ships in more than one language.

The whole book, free to read. Generated from the manuscript on every change.

Your progress

Tick each chapter in the sidebar once you have read and understood it. Your name and email keep the ticks on any device.

Your name and email are stored to save your progress. Nothing else is done with them.