A List Apart

The A List Apart Blog Presents:

Embeddable Comments? Yes, Please.

Article Continues Below

Some of you probably saw our Outside the Box blog post from earlier today — what you might not have noticed is that the sample comments in the post aren’t screenshots, nor are they simply fancied up blockquotes.

They’re a new feature we’re releasing today: embedded comments.

Just like tweets, you can now embed ALA comments anywhere you like. This is one of those features that we’ve been wanting for our own purposes, and then we figured: as long as we’re building it, let’s give everyone the ability to embed comments.

The embed code consists of markup representing the comment (as a fallback for if the script fails to load — for example, in an RSS feed) and an asynchronous script tag that fetches a live comment from our server using AJAX, the contents of which are injected into an iframe. By using AJAX to talk to a cross-origin enabled endpoint rather than simply setting the iframe’s src attribute, we avoid cross-domain security issues that might prevent us from manipulating the contents of the iframe.

The iframe then replaces the fallback markup, and voila — a real live embedded comment.

I really like the clipped logo, I’m amazed it annoys people so much.

— David Sparks on Outside the Box

The JavaScript work was handled by Mat, and Tim made ExpressionEngine jump through the required hoops. In a first for A List Apart, we’ve opened up the source code on GitHub—and there are more repos to come, so stay tuned.

We look forward to seeing what you do with it.

20 Reader Comments

Load Comments