Create a gist now

Instantly share code, notes, and snippets.

Load Disqus comments on click
<button class="disqus-button">View comments</button>
<div id="disqus_thread"></div>
<script async="true">
var disqus_config = function () {
this.page.url = YOUR_PAGE_URL;
this.page.identifier = YOUR_PAGE_IDENTIFIER;
},
button = document.getElementsByClassName('disqus-button')[0],
loadDisqus = function(e) {
e.preventDefault();
var d = document, s = d.createElement('script');
button.className = 'disqus-button--hidden';
s.src = '//YOUR_SITE_NAME.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
};
button.addEventListener('click', loadDisqus);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment