Ensure chat javascript is executed only when the chat itself is actually a part of the DOM
This may not be the case at the time of rendering, e.g. because the chat is rendered inside of a <template> tag and appended to the document at a later moment.