Subtle audio feedback gives interactive interfaces physical weight—a dry detent when inspecting a diagram node, a soft fifth glide when flipping a mode switch, or a quiet chime when a deployment completes. Yet almost every UI sound guide starts the same way: download a folder of MP3 or WAV files, host them on a CDN, preload them into Audio elements, and wire up event listeners in JavaScript.
That approach breaks down fast on performance-sensitive sites. Even a handful of small audio clips adds 80 to 200 KB of binary payloads, introduces decode latency on first click, triggers CORS and Content-Security-Policy friction, and locks out marketing teams, Webflow builders, and Shopify merchants who just want tactile feedback on a few controls without touching a bundler.
| Dimension | MP3/WAV Pack | Tono (Web Audio) |
|---|---|---|
| Gzipped Footprint | 120–240 KB | < 2 KB |
| External Audio Fetches | 8+ HTTP requests | 0 files |
| Non-Engineer HTML Mode | Manual JS wiring | tono="hover-tick" |
| Reduced-Motion Respect | Rarely wired | Automatic |
Evolution: From isoMapSounds.ts to a Dual-Mode Kit
Tono did not start as an open-source package. It began as a single helper named isoMapSounds.ts inside an interactive luxury commerce architecture presentation. When walking stakeholders through a multi-stage migration diagram, hovering prisms and stepping through stages felt noticeably clearer with quiet procedural sound cues—and because the pitch had to stay razor-light, shipping MP3 assets was off the table.
Once we realized every storefront prototype and engineering tool needed the exact same eight micro-sounds (hover-tick, stage-drop, switch, zoom-in, zoom-out, confirm, error, tap), we extracted that helper into a zero-dependency library with two equal entry points: a drop-in jsDelivr script driven by declarative HTML attributes, and a typed ESM module for React, Vite, and TypeScript apps.
- Zero-build HTML mode: load one deferred script tag and annotate any element with
tono="hover-tick"ortono="click:confirm". - Typed ESM mode: import
createTono()with explicitvolume,pitch,hoverThrottleMs, andstorageKeycontrols. - Document-level event delegation: a single lightweight listener handles dynamically rendered DOM nodes without per-button listener leaks.
<script defer src="https://cdn.jsdelivr.net/gh/roier/tono@1.0.0/dist/tono.min.js"></script>
<button tono="hover-tick">Inspect Node</button>
<button tono="click:confirm">Deploy Release</button>
<a href="/lab/tono" tono="hover:hover-tick click:tap">Try Soundboard</a>Synthesizing Tactile Physics Without Speaker Pops
Naive Web Audio snippets often sound harsh because stopping an oscillator abruptly creates an audible DC click. Every Tono voice shapes its GainNode with a fast attack ramp and an exponential decay down to 0.0001 before calling stop(), keeping transients crisp and warm even on laptop speakers.
Browsers also suspend new AudioContext instances until a trusted user gesture occurs. Tono constructs the context lazily on the first eligible pointer or keyboard interaction, calls resume() when suspended, throttles rapid pointer glides with a 65 ms hover gate, persists mute state in localStorage, and automatically silences itself when prefers-reduced-motion: reduce is enabled unless explicitly overridden.
import { createTono } from "@roier/tono";
const tono = createTono({
volume: 0.85,
hoverThrottleMs: 65,
respectReducedMotion: true,
storageKey: "tono:muted",
});
// Plug directly into interactive controls or Axon diagrams
tono.play("stage-drop");
tono.play("confirm", { pitch: 1.04 });