2HAASStart a project
All posts

Blog

Code Snippets.

Short pieces of code that solve one problem, with the reasoning behind them.

4 postsRSS feed

  1. 2 min read

    Web Workers: move heavy work off the main thread

    Heavy JavaScript freezes the page because it shares a thread with the interface. A Web Worker runs that work in the background. A working example and the limits to know.

  2. 2 min read

    Promise.allSettled: keep the results that succeeded

    Promise.all throws away every result when one request fails. Promise.allSettled waits for all of them and reports each outcome, so one failure cannot empty a page.

  3. 2 min read

    Intersection Observer: react when elements scroll into view

    Scroll listeners that measure element positions are slow and fiddly. Intersection Observer tells you when an element enters the viewport, with a few lines of code.

  4. 2 min read

    structuredClone: deep copy objects in JavaScript

    The spread operator copies only one level, and the JSON trick loses dates and breaks on cycles. structuredClone makes a true deep copy with one built-in call.

Tell us what’s in the way.

A few lines is enough. You get a candid yes, a candid no, or a sharper question.

  • Working software in week four
  • A reply in one business day
  • Handover is the deliverable

Prefer email? [email protected]

The problem, who it is for, and what is in the way right now.

One business day to a real reply. No sales sequence, no call required.