Looking to call a function only when the Intercom ( window.Intercom ) object is made available.
Best answer by Preston H
View originalLooking to call a function only when the Intercom ( window.Intercom ) object is made available.
Best answer by Preston H
View originalHey @preston h​, can you explain a bit more about your use case here?
@eric f11​ of course! We've deferred the loading of the intercom widget until the user's first interaction with the page (click, scroll, mousemove) to help with FCP. With that being said there could be a small chance that when we run an update (Intercom('update', { .. })), or some other command, that the Intercom object is not yet available and would throw exceptions.
Â
Some of the other third party libraries we're integrating with have callback functions that trigger when the lib is available to help ensure you're not attempting to use an undefined object.
Â
@roy s11​, as someone who knows a lot about custom JS setups for Intercom, would you be able to advise here?
I ended up adding an onload event to the generated script tag Intercom adds to the DOM.
Already have an account? Login
No account yet? Create an account
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.