title: How to remove freshchat window from other pages in Vuejs?
body: <p>I need to remove fresh chat window from all pages except the home page. I put the script inside the home component mounted part. But once it loads it never closes. If I refresh the page it disappears. I think it's because of the SPA. I think once it loads the JS it does not clear the header script.</p>
  <pre class="lang-js prettyprint-override"><code>mounted() {
      function initFreshChat() {
          window.fcWidget.init({
              token: &quot;***&quot;,
              host: &quot;https://wchat.freshchat.com&quot;
          });
      }
  
      function initialize(i, t) {
          var e;
          i.getElementById(t) ? initFreshChat() : ((e = i.createElement(&quot;script&quot;)).id = t, e.async = !0, e.src = &quot;https://wchat.freshchat.com/js/widget.js&quot;, e.onload = initFreshChat, i.head.appendChild(e))
      }
  
      function initiateCall() {
          initialize(document, &quot;freshchat-js-sdk&quot;)
      }
      window.addEventListener ? window.addEventListener(&quot;load&quot;, initiateCall, !1) : window.attachEvent(&quot;load&quot;, initiateCall, !1);
  }
  </code></pre>