Created
March 17, 2016 11:14
-
-
Save grahamlicence/4906f11912f2c2739d0c to your computer and use it in GitHub Desktop.
Load Disqus comments on click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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