1 import onmount from 'onmount'
2 import injectDisqus from '../helpers/inject_disqus'
5 * Delay disqus by some time. It's at the bottom of the page, there's no need
6 * for it to load fast. This will give more time to load more critical assets.
9 const DISQUS_DELAY = 100
12 * Injects Disqus onto the page.
15 onmount('[data-js-disqus]', function () {
16 const data = JSON.parse(this.getAttribute('data-js-disqus'))
17 const $parent = this.parentNode
18 $parent.setAttribute('hidden', true)
20 window.disqus_config = function () {
21 this.page.url = data.url
22 this.page.identifier = data.identifier
25 // Disqus takes a while to load, don't do it so eagerly.
26 window.addEventListener('load', () => {
28 injectDisqus(data.host)
29 $parent.removeAttribute('hidden')