I am facing an issue with the fresh chat window on my website. I want to remove it from all pages except the home page. I have placed the script inside the mounted part of the home component, but once it loads, it never closes. It only disappears if I refresh the page. I suspect this is due to the SPA architecture where the JavaScript is not clearing the header script properly.
mounted() {
function initFreshChat() {
window.fcWidget.init({
token: "***",
host: "https://wchat.freshchat.com"
});
}
function initialize(i, t) {
var e;
i.getElementById(t) ? initFreshChat() : ((e = i.createElement("script")).id = t, e.async = !0, e.src = "https://wchat.freshchat.com/js/widget.js", e.onload = initFreshChat, i.head.appendChild(e))
}
function initiateCall() {
initialize(document, "freshchat-js-sdk")
}
if (window.addEventListener) {
window.addEventListener("load", initiateCall, !1);
} else {
window.attachEvent("load", initiateCall, !1);
}
}