Skip to main content

Looking to call a function only when the Intercom ( window.Intercom ) object is made available.

Hey @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.


Reply