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.
window.addEventListener("MOE_LIFECYCLE",function(e){
if(e.detail.name === "SDK_INITIALIZED"){
console.log(e.detail.data)
// write you code here
}
if(e.detail.name === "SETTINGS_FETCHED"){
console.log(e.detail.data)
// write you code here
}
})