Once you create a Hequalizer instance, it continues to maintain accurate height equalization automatically across several common scenarios: web font rendering, viewport resizing, and dynamic content changes. Understanding each mechanism helps you configure the library correctly and avoid subtle layout bugs.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/soyleninjs/hequalizer/llms.txt
Use this file to discover all available pages before exploring further.
Font loading
Hequalizer defers its initialinit() call until document.fonts.ready resolves:
init() ran before fonts loaded, the measured heights would be based on fallback font metrics and would be wrong. Waiting for document.fonts.ready ensures that all web fonts are available before any element heights are measured.
main.js
Resize listener
Duringinit(), each instance registers a resize listener on window:
- Calls
_setActualOptions()to re-evaluate breakpoints and updateactualOptionsandactualBreakpoint. - Cancels any pending debounce timeout (
window.clearTimeout). This always happens — even whenobserveResizeisfalse. - If
observeResizeisfalsefor the now-active options, the handler returns immediately without recalculating or emitting an event. - If
debounceis0(the default), recalculation happens synchronously on each resize event. - If
debounceis a positive number, recalculation is deferred by that many milliseconds; a new timeout is started, and will be cancelled by the next resize event that fires before it elapses.
Disabling resize recalculation
SetobserveResize: false to prevent recalculation on resize for the active options set. The resize listener remains registered — it still updates actualOptions and actualBreakpoint — but it will not re-measure or update CSS variables:
main.js
Smoothing resize with debounce
By default,debounce: 0 means Hequalizer recalculates on every single resize event, which can fire dozens of times per second while a user drags the window edge. Use debounce to add a delay:
main.js
debounce: 150, Hequalizer waits 150 milliseconds after the last resize event before recalculating. If another resize event fires during that window, the timeout resets.
Content change observer (MutationObserver)
Afterinit(), Hequalizer attaches a MutationObserver to each element in the group. The observer watches for three types of changes:
childList— child elements added or removedsubtree— changes anywhere inside the element’s subtreecharacterData— text node content changes
hequalizer:{handle}:change:
main.js
update() manually when an element’s text or inner HTML changes dynamically — Hequalizer detects and responds to it automatically.
Adding or removing elements
The MutationObserver watches the content of existing elements, not the parent container for new siblings. If your application dynamically adds or removes elements that carry adata-hequalizer attribute, Hequalizer will not detect them automatically.
After any DOM mutation that adds or removes group elements, call refreshElements():
main.js
refreshElements() disconnects all existing observers, re-runs querySelectorAll with the original handle to pick up any new or removed elements, recalculates heights, then re-attaches observers to the updated element list.
Recalculation trigger summary
All five automatic and manual recalculation paths, along with the custom events they emit:| Trigger | Method called | Event emitted |
|---|---|---|
| Font load complete | init() | hequalizer:{handle}:init |
| Window resize | internal (_updateAfterResize) | hequalizer:{handle}:resize |
| Content change (MutationObserver) | internal (_updateAfterChanges) | hequalizer:{handle}:change |
| Manual recalculation | update() | hequalizer:{handle}:update |
| Manual element re-query | refreshElements() | hequalizer:{handle}:refresh |
update() recalculates heights using the current $elements list — it does not re-query the DOM. If elements have been added or removed since the instance was created, use refreshElements() instead, which runs a fresh querySelectorAll to pick up the changes.window and carry the Hequalizer instance in event.detail.instance:
main.js