Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Loads Disqus comments on click with native JavaScript. Opens comments when linked to directly.
<div class="comments-block">
<button id="show-comments" onclick="disqus();return false;">Load Comments</button>
<div id="disqus_thread"></div>
var disqus_loaded = false;
var disqus_shortname = 'xxxx'; //Add your shortname here
function disqus() {
if (!disqus_loaded) {
disqus_loaded = true;
var e = document.createElement("script");
e.type = "text/javascript";
e.async = true;
e.src = "//" + disqus_shortname + "";
(document.getElementsByTagName("head")[0] ||
//Hide the button after opening
document.getElementById("show-comments").style.display = "none";
//Opens comments when linked to directly
var hash = window.location.hash.substr(1);
if (hash.length > 8) {
if (hash.substring(0, 8) == "comment-") {
//Remove this if you don't want to load comments for search engines
if(/bot|google|baidu|bing|msn|duckduckgo|slurp|yandex/i.test(navigator.userAgent)) {

This comment has been minimized.

Copy link

commented Mar 5, 2018

Is it really Increase website loading speed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.