Skip to main content
JavaScript
if (window.SmileUI) {
  // SmileUI has loaded
} else {
  document.addEventListener("smile-ui-loaded", () => {
    // SmileUI has loaded
  });
}
This method allows you to detect when the SmileUI object has been loaded and is available for use on the page. A corresponding smile-ui-loaded DOM event is also fired when initialization has completed. Combining these two approaches is useful for wrapping any code (or other SDK methods) that make use of the SmileUI object.

Returns

This method returns an instance of the SmileUI object, or null if the SmileUI object has not yet finished loading.
An object as a return value does NOT mean that Smile.js has been initialized. To check for initialization after load, use the SmileUI.ready() method.