2HAASStart a project
All posts

Blog

Code Snippets.

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

6 postsRSS feed

  1. 4 min read

    Simplify Popups with HTML Popover API

    Learn how to effortlessly create accessible popups, tooltips, and modals using the native HTML Popover API, reducing custom JavaScript and improving user experience.

  2. 4 min read

    Simplify Promise Handling with Promise.withResolvers

    Learn how the new Promise.withResolvers static method streamlines common asynchronous patterns in JavaScript, reducing boilerplate and improving code clarity.

  3. 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.

  4. 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.

  5. 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.

  6. 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? hello@2haas.com

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.