Last active
August 29, 2015 14:06
-
-
Save ardouglass/84ce96f9b7859bc735e5 to your computer and use it in GitHub Desktop.
So what if I want to do use Disqus on an AJAX page, but I don't want it to load the comments until someone clicks?
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
var load_disqus = function (identifier) { | |
var disqus_shortname = 'example'; | |
var disqus_identifier = identifier; | |
var disqus_url = "http://example.com/" + identifier; | |
if(typeof DISQUS === "undefined") { | |
/* * * DON'T EDIT THIS BLOCK FROM DISQUS * * */ | |
(function() { | |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); | |
})(); | |
} else { | |
DISQUS.reset({ | |
reload: true, | |
config: function () { | |
this.page.identifier = disqus_identifier; | |
this.page.url = disqus_url; | |
} | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment