Waiting for the PopupHero SDK to initialize

Fatos Bediu
Founder & Developer answerly.io
It might take a few milliseconds for the PopupHero widget to load on your website and initialize the SDK fully.
Since this is the case, accessing the SDK directly on your website will throw errors since your code might run before the SDK has been initialized.
Fortunately, PopupHero widget emits an event PopupHero:Loaded
to the main window, which you should listen to and only use the SDK after that event has been fired.
For example:
window.addEventListener('PopupHero:Loaded', () => {
// SDK is available here
// example code
Answerly.PopupHero.show();
});
Did we answer your question?
😃 🤔 ☹️
How can we improve this answer?