icon: star#
Primary Operations#
These are the three functions you use to manage menus.
Typical flow#
- Optionally warm up assets with
PreloadMenu. - Show the menu with
LoadMenu. - Remove it with
UnloadMenu.
Guidance for menu scripts#
Write your menu JS to only touch menuContainer. That keeps cleanup simple on UnloadMenu.
Prefer scoped queries:
const closeBtn = menuContainer.querySelector("[data-action='close']");
closeBtn?.addEventListener("click", () => UnloadMenu(menuId));
Use extraData for dynamic input. Avoid reaching into unrelated globals when possible.
{% hint style="info" %}
Avoid loading the same menuId twice. Duplicate id="dMenu_<menuId>" breaks UnloadMenu.
{% endhint %}