Event

liquid-ajax-cart:init

An event which is fired at the document when Liquid Ajax Cart is initialized.

Use case

Use this event along with the liquidAjaxCart.init property when you want to run your JavaScript once Liquid Ajax Cart is initialized.

assets/script.js
function runWhenInit() {
  console.log("The current cart state is: ", window.liquidAjaxCart.cart);
}

if (window.liquidAjaxCart?.init) {
  // if Liquid Ajax Cart is already initialized
  runWhenInit();
} else {
  // wait for Liquid Ajax Cart to be initialized
  document.addEventListener("liquid-ajax-cart:init", runWhenInit);
}