Dynamic Application API

init()

async

Triggers the initialization of DOM elements on the page.

  • Accepts an optional string argument that specifies the event type, which can be any custom type, such as: "ready", "load", "spa", "content", "tpl", or "custom".
    This type will be included in the event object.
  • Initialization will be triggered for DOM elements that are not yet initialized and have the following attributes:
    "data-ready"
    "data-load"
    "data-tpl"
    "data-resize"
    "data-visible"
    "data-invisible"
    "data-resize-in"
    "data-visible-in"
    "data-invisible-in"
  • DOM elements with the "data-init" attribute will always be initialized each time the process runs, even if they have already been processed.
    The event object will include a "raw" property that indicates whether the element has been previously initialized, using a boolean value:
    true – the element has not been initialized yet.
    false – the element has already been initialized.
  • DOM elements with the "data-ready" attribute will only be processed when the method is executed with the "ready" argument.
    Similarly, DOM elements with the "data-load" attribute are processed only when the method is executed with the "load" argument.
  • Initialization is automatically triggered when the HTML document is fully parsed, as well as during navigation without a page reload, when updating content, or managing templates, and there is no need for manual triggering.
  • It is not necessary to wait for the method to be executed using await if not needed.
Example:
// Triggers initialization without an argument.
init();

// Triggers initialization with the "ready" argument.
init('ready');

// Triggers initialization with the "myEvent" argument and waits for it to complete.
await init('myEvent');