Optimize Disqus to make DCL happen sooner
This commit is contained in:
parent
9d16265a85
commit
5c6a897401
|
@ -19,6 +19,4 @@
|
||||||
</details>
|
</details>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script id='dsq-count-scr' src='//{{ site.data.disqus.host }}/count.js' async></script>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import onmount from 'onmount'
|
import onmount from 'onmount'
|
||||||
import injectDisqus from '../helpers/inject_disqus'
|
import injectDisqus from '../helpers/inject_disqus'
|
||||||
|
import ready from 'dom101/ready'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects Disqus onto the page.
|
* Injects Disqus onto the page.
|
||||||
|
@ -13,5 +14,8 @@ onmount('[data-js-disqus]', function () {
|
||||||
this.page.identifier = data.identifier
|
this.page.identifier = data.identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
injectDisqus(data.host)
|
// Disqus takes a while to load, don't do it so eagerly.
|
||||||
|
ready(() => {
|
||||||
|
injectDisqus(data.host)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,13 +2,27 @@
|
||||||
* Injects disqus's scripts into the page.
|
* Injects disqus's scripts into the page.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* injectDisqus('devhints.disqus.com')
|
* inject('devhints.disqus.com')
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function injectDisqus (host) {
|
export default function inject (host) {
|
||||||
|
injectEmbed(host)
|
||||||
|
injectCount(host)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function injectEmbed (host) {
|
||||||
const d = document
|
const d = document
|
||||||
const s = d.createElement('script')
|
const s = d.createElement('script')
|
||||||
s.src = 'https://' + host + '/embed.js'
|
s.src = `https://${host}/embed.js`
|
||||||
s.setAttribute('data-timestamp', +new Date())
|
s.setAttribute('data-timestamp', +new Date())
|
||||||
;(d.head || d.body).appendChild(s)
|
;(d.head || d.body).appendChild(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function injectCount (host) {
|
||||||
|
const d = document
|
||||||
|
const s = d.createElement('script')
|
||||||
|
s.src = `https://${host}/count.js`
|
||||||
|
s.id = 'dsq-count-scr'
|
||||||
|
s.async = true
|
||||||
|
;(d.head || d.body).appendChild(s)
|
||||||
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -33,7 +33,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "6.26.0",
|
"babel-polyfill": "6.26.0",
|
||||||
"dom101": "2.0.1",
|
"dom101": "2.1.0",
|
||||||
"hint.css": "2.5.0",
|
"hint.css": "2.5.0",
|
||||||
"isotope-layout": "3.0.4",
|
"isotope-layout": "3.0.4",
|
||||||
"jquery": "3.2.1",
|
"jquery": "3.2.1",
|
||||||
|
|
|
@ -1720,9 +1720,9 @@ doctrine@^2.0.0:
|
||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
isarray "^1.0.0"
|
isarray "^1.0.0"
|
||||||
|
|
||||||
dom101@2.0.1:
|
dom101@2.1.0:
|
||||||
version "2.0.1"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/dom101/-/dom101-2.0.1.tgz#b40f643ce977e30989014bce40479bceef0ff29a"
|
resolved "https://registry.yarnpkg.com/dom101/-/dom101-2.1.0.tgz#45fcee0100e078591696bec6e75276b5d03c0b5c"
|
||||||
|
|
||||||
domain-browser@^1.1.1:
|
domain-browser@^1.1.1:
|
||||||
version "1.1.7"
|
version "1.1.7"
|
||||||
|
|
Loading…
Reference in New Issue