Skip to content

Instantly share code, notes, and snippets.

@ardouglass
Last active August 29, 2015 14:06
Show Gist options
  • Save ardouglass/84ce96f9b7859bc735e5 to your computer and use it in GitHub Desktop.
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?
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