MurhafSousli/ngx-disqus

Duplicated disqus scripts and styles in the head tag

omandryk opened this issue · 1 comments

Hi @MurhafSousli,

I'm using ngx-disqus in my Angular 6 application and I've noticed that disqus scripts and styles are duplicated in the head tag when I navigate between pages with Disqus comments using routerLink:

<head>
  <meta charset="utf-8">
  <title>NgxDisqusDemo</title>
  <base href="/">

<link rel="preload" as="style" href="https://c.disquscdn.com/next/embed/styles/lounge.22793468229c73f9fca4769dbeac76cf.css">
<link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/common.bundle.e63a160a6bfb2f2953b5059c50baaf15.js">
<link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/lounge.bundle.21354d142caebf813d50d9d69641db45.js">
<link rel="preload" as="script" href="https://disqus.com/next/config.js">

<script src="https://c.disquscdn.com/next/embed/alfalfa.4a5fcca1fe50a757044dfd331b660625.js" async="" charset="UTF-8"></script>
<link rel="preload" as="style" href="https://c.disquscdn.com/next/embed/styles/lounge.22793468229c73f9fca4769dbeac76cf.css">
<link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/common.bundle.e63a160a6bfb2f2953b5059c50baaf15.js">
<link rel="preload" as="script" href="https://c.disquscdn.com/next/embed/lounge.bundle.21354d142caebf813d50d9d69641db45.js">
<link rel="preload" as="script" href="https://disqus.com/next/config.js">

</head>

I've created a demo project where you can easily reproduce this issue by navigating between "hello" and "page" pages few times and then inspecting head tag: https://github.com/icoderman/ngx-disqus-demo

Could you please take a look on it and let me to know if it is a bug or maybe I'm doing something wrong.

Thank you in advance!
-Oleksandr

Hi @icoderman, I made a reproduction here. I see that, this is because of the disqus is set to undefined on component destroy function.

ngOnDestroy() {
this.dService.window.DISQUS = undefined;

It seems to be fixed in this stackblitz