2.0.0
[2.0.0] — 2026-02-22
This is a full rewrite of Height Harmony. The v1 API is preserved — heightHarmony('.card') still works as a drop-in — but the internals, options, and output formats are entirely new.
Added
Core library
ResizeObserverintegration — Heights re-sync automatically whenever any element changes size, with nowindow.resizelistener neededMutationObserverintegration — Watches parent containers for new or removed elements; new cards/items picked up automatically with no manual re-init- Options object — Pass a configuration object as the second argument:
debounce(number, default0) — milliseconds to debounce observer callbacks;0usesrequestAnimationFrameonlyminHeight(boolean, defaultfalse) — usemin-heightinstead ofheight, letting elements grow taller than the max if content is addedbreakpoint(number, default0) — disable equalizing below this viewport width (px); useful for letting mobile layouts stack naturallywatch(boolean, defaulttrue) — setfalseto skip observer setup (fire-and-forget mode)transitions(boolean, defaulttrue) — apply a0.2s easeCSS transition on height changes for smooth animation
HeightHarmonyInstanceclass with chainable instance methods:.refresh()— manually trigger a height re-calculation.destroy()— disconnect all observers, remove all inlineheight/min-height/transitionstyles, and mark the instance as destroyed
heightHarmony.autoInit(opts?)static method — scans the document for[data-hh-group]attributes and harmonizes each group automatically; returns an array of instancesdata-hh-groupHTML attribute — declarative markup API; elements sharing the same group name are equalized together with a singleautoInit()callheightHarmony.versionstatic property — returns"2.0.0"- ESM build (
dist/height-harmony.es.js) — tree-shakeable ES module for bundlers - UMD build (
dist/height-harmony-min.js) — works as a plain<script>tag, CommonJSrequire, or AMD define; exposeswindow.heightHarmonyglobally - Fallback for old browsers — automatically falls back to a debounced
window.resize+orientationchangelistener whenResizeObserveris unavailable (e.g., very old Safari)
Build & tooling
- Vite + Terser build pipeline — produces minified, optimised ESM and UMD bundles in a single command (
npm run build)
Project
- Published to the public NPM registry as
height-harmony(previously only available as a GitHub Package) - Demo site extracted into a separate private repo (
height-harmony-site); Vercel deployment is managed there
Fixed
- Listener leak —
resizeevent —destroy()now correctly calls the stored_cleanupFallback()function to remove thewindow.resizelistener added by the ResizeObserver fallback path. Previously the listener remained attached forever afterdestroy(). - Listener leak —
orientationchangeevent — Theorientationchangelistener (also part of the fallback path) was never removed. It is now named, stored in_cleanupFallback, and removed bydestroy(). - Style leak —
transitioninline property — Whentransitions: true, Height Harmony sets atransition: height 0.2s easeinline style. Previouslydestroy()did not remove this property, leaving a lingering inline style that could interfere with other CSS animations.destroy()now callsel.style.removeProperty('transition').
Removed
naturalHeight()internal helper — was defined in the source but never called; the sync routine usesoffsetHeightdirectly after clearing inline heights in a single batch
Published package contents
| File | Size | Gzipped |
|---|---|---|
height-harmony.js (source) |
11.0 kB | — |
dist/height-harmony.es.js |
7.1 kB | 2.15 kB |
dist/height-harmony-min.js |
4.0 kB | 1.56 kB |
README.md |
6.9 kB | — |
LICENSE |
1.1 kB | — |
Migration from v1
v1 had a single export with no options:
heightHarmony('.card'); // v1 — still works in v2 ✅Everything is backwards-compatible. The only breaking change is the package name. Existing CSS, HTML, and JavaScript that calls heightHarmony(selector) requires no changes.
[1.x] — Prior releases
Version 1.x was a minimal single-function utility with no options, no observers, and a window resize listener only. It was distributed exclusively via the GitHub Package Registry as @byronjohnson/height-harmony.