> ## Documentation Index
> Fetch the complete documentation index at: https://moengage.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Web SDK Lifecycle Callbacks

> Listen for MoEngage Web SDK lifecycle events like initialization and settings fetch completion.

There are cases where you might want to wait for the SDK to be initialised completely to do some action. Or you may need to trigger something when the SDK settings are fetched (cached in the browser for 24 hours).

SDK emits events on its various life cycles which can be listened to use it.

<CodeGroup>
  ```javascript JavaScript wrap theme={null}
  window.addEventListener("MOE_LIFECYCLE", function(e) {
    if (e.detail.name === "SDK_INITIALIZATION_COMPLETED") {
      console.log(e.detail.data);
      // write your code here
    }
    
    if (e.detail.name === "SETTINGS_FETCHED") {
      console.log(e.detail.data);
      // write your code here
    }
  });
  ```
</CodeGroup>
