9

Does anyone know how disqus works?

It manages comments on a blog, but the comments are all held on third-party site. Seems like a neat use of cross-site communication.

Toby Hede
  • 36,755
  • 28
  • 133
  • 162

7 Answers7

8

The general pattern used is JSONP

Its actually implemented in a fairly sophisticated way (at least on the jQuery site) ... they defer the loading of the disqus.js and thread.js files until the user scrolls to the comment section.

The thread.js file contains json content for the comments, which are rendered into the page after its loaded.

Community
  • 1
  • 1
Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
  • 7
    JSONP might be used to load the comments, but all interaction with the input text area is done using easyXDM. – Sean Kinsey Jul 19 '11 at 10:01
2

Quoting Anton Kovalyov's (former engineer at Disqus) answer to the same question on a different site that was really helpful to me:

Disqus is a third-party JavaScript application that runs in your browser and injects itself on publishers' websites. These publishers need to install a small snippet of JavaScript code that makes the first request to our servers and loads initial JavaScript loader. This loader then creates all necessary iframe elements, gets the data from our servers, renders templates and injects the result into some element on the page.

As you can probably guess there are quite a few different technologies supporting what seems like a simple operation. On the back-end you have to run and scale a gigantic web application that serves millions of requests (mostly read). We use Python, Django, PostgreSQL and Redis (for our realtime service).

On the front-end you have to minimize your payload, make sure your app is super fast and that it doesn't break in extremely hostile environments (you will be surprised how screwed up publisher websites can be). Cross-domain communication—ability to send messages from hosting website to your servers—can be tricky as well.

Unfortunately, it is impossible to explain how everything works in a comment on Quora, or even in an article. So if you're interested in the back-end side of Disqus just learn how to write, run and operate highly-scalable websites and you'll be golden. And if you're interested in the front-end side, Ben Vinegar and myself (both front-end engineers at Disqus) wrote a book on the topic called Third-party JavaScript (http://thirdpartyjs.com/).

I'm planning to read the book he mentioned, I guess it will be quite helpful.

Here's also a link to the official answer to this question on the Disqus site.

Community
  • 1
  • 1
machinery
  • 3,793
  • 4
  • 41
  • 52
2

You have three options when adding Disqus commenting to a site:

The main advantage of the integrated solutions is that they're easy to set up. In the case of WordPress, for example, it's as easy as activating a plug-in.

Having the ability to communicate with the API directly is very useful, and offers two advantages over the other options. First, it gives you as the developer complete control over the markup. Secondly, you're able to process comments server-side, which may be preferable.

davidchambers
  • 23,918
  • 16
  • 76
  • 105
  • 1
    I was looking at more of a technical insight into how they do what they do, for a project with some similar requirements. – Toby Hede Aug 14 '10 at 00:15
2

Looks like that using easyXDM library, which uses the best available way for current browser to communicate with other site.

equeny
  • 96
  • 1
  • 7
0

short answer? AJAX, you get your own url eg "site.com/?comments=ID" included via javascript... but with real time updates like that you would need a polling server.

John
  • 1
  • Yes. But how does posting work? Is it wrapping an iframe (FB-connect style)? – Toby Hede Mar 10 '10 at 23:00
  • @Toby Hede: Yes, check out any site using Disqus and inspect the textarea element. It's sitting inside an iframe that points to your-site-name.disqus.com. – treeface Feb 04 '11 at 19:36
0

I think they keep the content on their site and your site will only send & receive the data to/from disqus. Now I wonder what happens if you decide that you want to bring your commenting in house without losing all existing comments!. How easy would you get to your data I wonder? They claim that the data belongs to you, but they have the control over it, and there is not much explanation on their site about this.

Val Neekman
  • 17,692
  • 14
  • 63
  • 66
  • One more thing I add: If you use their APIs to fetch the comments and then display it, then you can make it SEO friendly as the search engines are able to pick that up. If you let their JS to pull the comments onto your pages, then that might not be SEO friendly as search bots usually can't candle AJAX calls. (according to Google's techie girl on youtube). The advantage of using AJAX is that your backend will not care about the performance of Disqus, and your pages load up pretty fast. – Val Neekman Sep 08 '10 at 13:56
0

I'm always leaving comment in disqus platform. Sometimes, comment seems to be removed once you refreshed it and sometimes it's not. I think the one that was removed are held for moderation without saying it.

plumbing
  • 9
  • 1