Skip to main content

injectScript()

This is a lower level version of injectChatScriptByVersion. It is recommended to use injectChatScriptByVersion unless you have a good reason to use this function. Here is the API in case you need it:

/**
* Injects the chat SDK into the document. Needs to be called before calling initialize()
*
* @param id - a unique id that will be set as the script id
* @param src - the link pointing to the chat sdk script
* @param callback - Any function that should be run after the script loads. initialize()
* is commonly passed here to init only after the script fully loads
* @param async(optional) - whether the script should be loaded asynchronously. default: false
* @param defer(optional) - whether the script should be loaded with defer. default: false
* @param nonce(optional) - optional custom nonce to use for the script
*/
export const injectScript = async (
{
id,
src,
async = false,
defer = false,
nonce,
}: { id: string; src: string; async?: boolean; defer?: boolean; nonce?: string },
callback?: () => Promise<void>
): Promise<void>;