开发者

How does disqus work?

开发者 https://www.devze.com 2022-12-22 06:17 出处:网络
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. The general pa

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.


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.


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

  • Use one of the many integrated solutions (WordPress, Blogger, Tumblr, etc. are supported)
  • Use the universal JavaScript code
  • Write your own code to communicate with the Disqus API

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.


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


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号