Improved Disqus integration to be non-blocking

This commit is contained in:
squidfunk 2020-08-28 18:26:55 +02:00
parent 355a1cacd5
commit 96f58edae6
2 changed files with 14 additions and 12 deletions

View File

@ -8,5 +8,5 @@
{% if not page.is_homepage and disqus %}
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script>var disqus_config=function(){this.page.url="{{ page.canonical_url }}",this.page.identifier="{{ page.canonical_url | replace(config.site_url, '') }}"};!function(){var e=document,i=e.createElement("script");i.src="//{{ disqus }}.disqus.com/embed.js",i.setAttribute("data-timestamp",+new Date),(e.head||e.body).appendChild(i)}()</script>
<script>window.addEventListener("load",function(){var e,t;e=document,(t=e.createElement("script")).src="//{{ disqus }}.disqus.com/embed.js",t.setAttribute("data-timestamp",+new Date),(e.head||e.body).appendChild(t)})</script>
{% endif %}

View File

@ -31,16 +31,18 @@
<h2 id="__comments">{{ lang.t("meta.comments") }}</h2>
<div id="disqus_thread"></div>
<script type="application/javascript">
var disqus_config = function () {
this.page.url = "{{ page.canonical_url }}";
this.page.identifier =
"{{ page.canonical_url | replace(config.site_url, '') }}";
};
(function() {
var d = document, s = d.createElement("script");
s.src = "//{{ disqus }}.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
window.addEventListener("load", function() {
var disqus_config = function () {
this.page.url = "{{ page.canonical_url }}";
this.page.identifier =
"{{ page.canonical_url | replace(config.site_url, '') }}";
};
(function() {
var d = document, s = d.createElement("script");
s.src = "//{{ disqus }}.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
})
</script>
{% endif %}