Comparing Embeds from Short-Form Social Media Sites
It is sometimes useful to embed the contents from one website into another. For example, you may wish to quote a post from a microblogging site like Twitter, Threads, BlueSky, or Mastodon.
All of them offer an "embed" button which will copy a snippet of code for you to paste into your website. Here's how they compare:
BSky
In my considered opinion, BlueSky is the only modern service which does embedding correctly. The full text is placed in a <blockquote>
, with a link back, links to any attached content, and the datetime of the post. It is then progressively enhanced with JS to show the full content:
HTML<blockquote class="bluesky-embed" data-bluesky-uri="at://did:plc:i6misxex577k4q6o7gloen4s/app.bsky.feed.post/3l23zp5prxl2e" data-bluesky-cid="bafyreidnqkzlze2paez2g5gbk7ar3phgxilrxfhkikr263grp7gizeoime">
<p lang="en">This is a test to compare how BSky, Mastodon, Twitter, and Threads do HTML embeds.
😊
example.com
👻
#Testing<br>
<br>
<a href="https://bsky.app/profile/did:plc:i6misxex577k4q6o7gloen4s/post/3l23zp5prxl2e?ref_src=embed">[image or embed]</a>
</p>
— Terence Eden (<a href="https://bsky.app/profile/did:plc:i6misxex577k4q6o7gloen4s?ref_src=embed">@edent.tel</a>)
<a href="https://bsky.app/profile/did:plc:i6misxex577k4q6o7gloen4s/post/3l23zp5prxl2e?ref_src=embed">Aug 19, 2024 at 22:23</a>
</blockquote>
<script async src="https://embed.bsky.app/static/embed.js" charset="utf-8"></script>
It might be nice to have a smidge more semantics in there - but the overall experience is good. Hashtags, links, and user mentions could probably be linked. If the JS doesn't load, the text and essential information is available.
Mastodon
I'm not a fan of the Mastodon embed. It's an <iframe>
and nothing else. If the service goes down, the content of the message isn't preserved.
HTML<iframe src="https://mastodon.social/@Edent/112990799122059429/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe>
<script src="https://mastodon.social/embed.js" async="async"></script>
Mastodon's position is - reasonably - that authors can edit and delete their posts. Sites shouldn't hold on to outdated or destroyed data.
Note, some Mastodon sites present an embed button even if they have a CSP which prevents cross-site embedding.
Threads
Easily the worst experience. All you get is an <svg>
of the logo, the name of the person who posted, and a link back to the content. All mixed in to some <div>
soup.
HTML<blockquote class="text-post-media" data-text-post-permalink="https://www.threads.net/@_edent_/post/C-3dQXkOq6Q" data-text-post-version="0" id="ig-tp-C-3dQXkOq6Q" style=" background:#FFF; border-width: 1px; border-style: solid; border-color: #00000026; border-radius: 16px; max-width:540px; margin: 1px; min-width:270px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);">
<a href="https://www.threads.net/@_edent_/post/C-3dQXkOq6Q" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" target="_blank" rel="noopener">
<div style=" padding: 40px; display: flex; flex-direction: column; align-items: center;">
<div style=" display:block; height:32px; width:32px; padding-bottom:20px;">
<svg aria-label="Threads" height="32px" role="img" viewBox="0 0 192 192" width="32px" xmlns="http://www.w3.org/2000/svg"> <path d="M141.537 88.9883C140.71 88.5919 139.87 88.2104 139.019 87.8451C137.537 60.5382 122.616 44.905 97.5619 44.745C97.4484 44.7443 97.3355 44.7443 97.222 44.7443C82.2364 44.7443 69.7731 51.1409 62.102 62.7807L75.881 72.2328C81.6116 63.5383 90.6052 61.6848 97.2286 61.6848C97.3051 61.6848 97.3819 61.6848 97.4576 61.6855C105.707 61.7381 111.932 64.1366 115.961 68.814C118.893 72.2193 120.854 76.925 121.825 82.8638C114.511 81.6207 106.601 81.2385 98.145 81.7233C74.3247 83.0954 59.0111 96.9879 60.0396 116.292C60.5615 126.084 65.4397 134.508 73.775 140.011C80.8224 144.663 89.899 146.938 99.3323 146.423C111.79 145.74 121.563 140.987 128.381 132.296C133.559 125.696 136.834 117.143 138.28 106.366C144.217 109.949 148.617 114.664 151.047 120.332C155.179 129.967 155.42 145.8 142.501 158.708C131.182 170.016 117.576 174.908 97.0135 175.059C74.2042 174.89 56.9538 167.575 45.7381 153.317C35.2355 139.966 29.8077 120.682 29.6052 96C29.8077 71.3178 35.2355 52.0336 45.7381 38.6827C56.9538 24.4249 74.2039 17.11 97.0132 16.9405C119.988 17.1113 137.539 24.4614 149.184 38.788C154.894 45.8136 159.199 54.6488 162.037 64.9503L178.184 60.6422C174.744 47.9622 169.331 37.0357 161.965 27.974C147.036 9.60668 125.202 0.195148 97.0695 0H96.9569C68.8816 0.19447 47.2921 9.6418 32.7883 28.0793C19.8819 44.4864 13.2244 67.3157 13.0007 95.9325L13 96L13.0007 96.0675C13.2244 124.684 19.8819 147.514 32.7883 163.921C47.2921 182.358 68.8816 191.806 96.9569 192H97.0695C122.03 191.827 139.624 185.292 154.118 170.811C173.081 151.866 172.51 128.119 166.26 113.541C161.776 103.087 153.227 94.5962 141.537 88.9883ZM98.4405 129.507C88.0005 130.095 77.1544 125.409 76.6196 115.372C76.2232 107.93 81.9158 99.626 99.0812 98.6368C101.047 98.5234 102.976 98.468 104.871 98.468C111.106 98.468 116.939 99.0737 122.242 100.233C120.264 124.935 108.662 128.946 98.4405 129.507Z" />
</svg>
</div>
<div style=" font-size: 15px; line-height: 21px; color: #999999; font-weight: 400; padding-bottom: 4px; ">
Post by @_edent_
</div>
<div style=" font-size: 15px; line-height: 21px; color: #000000; font-weight: 600; ">
View on Threads
</div>
</div>
</a>
</blockquote>
<script async src="https://www.threads.net/embed.js"></script>
Twitter is adequate. The full text is preserved in the blockquote, it looks like media is linked to, but there's not much else.
HTML<blockquote class="twitter-tweet">
<p lang="en" dir="ltr">I've unfollowed everyone I once knew.<br><br>
If you're still following me here, please don't. There are other social networks which aren't run by a race-baiter.<br><br>
Come join us.<br><br>
Twitter was lovely for a while. But it is time to leave for good.<br><br>
If not now, then when?</p>— Terence Eden is on Mastodon (@edent)
<a href="https://twitter.com/edent/status/1820847547012858180?ref_src=twsrc%5Etfw">August 6, 2024</a>
</blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
What about Open Graph Protocol?
I've previously written about the moribund Open Graph Protocol standard. All of the sites except Twitter provide some of the contents of the post in the <meta>
elements of the page. That can be used to scrape the contents of the post, but it is a bit fiddly.
What's The User Need?
There is an inherent tension here. Different users have different needs, and there's no single right way of embedding.
Social media sites want their look-and-feel preserved - hence the need for progressive enhancement or iframes. They also often want to track users across the web.
Embedding websites want the content preserved if the original disappears. They also want something which looks recognisably like it comes from the social media site.
Users of social media sites want their edits and updates to be shown on the sites which are embedding them. They may also want their content removed from embedding sites when it is deleted.
Readers want to see the content - and they may not want their reading habits tracked by a social media site.
So, what to do?
Personally, I think BlueSky's approach is closest to optimal. Embed the full content, including media, and then enhance.
The ideal, I think, is to make a fully semantic HTML embed which can either have its own stylesheet and / or be progressively enhanced with a JavaScript.
Something like this:
HTML<blockquote class="social-embed" id="social-embed-1234" style="all:unset;" lang="en" itemscope itemtype="https://schema.org/SocialMediaPosting">
<header class="social-embed-header" itemprop="author" itemscope itemtype="https://schema.org/Person">
<a href="https://example.com/user" class="social-embed-user" itemprop="url">
<img class="social-embed-avatar" src="https://example.com/user/avatar" alt="" itemprop="image">
<div class="social-embed-user-names">
<p class="social-embed-user-names-name" itemprop="name">Full Username</p>
<p class="social-embed-user-names-name" itemprop="name">@username</p>
</div>
</a>
<img class="social-embed-logo" alt="" src="https://example.com/icon.png">
</header>
<section class="social-embed-text" itemprop="articleBody">
<p>Text</p>
<a href="https://example.com/user/image/123"><img src="https://example.com/user/image/123"></a>
</section>
<footer class="social-embed-footer">
<a href="https://example.com/user/1234">
<span aria-label="20 likes" class="social-embed-meta">❤️ 20</span>
<span aria-label="5 replies" class="social-embed-meta">💬 5</span>
<span aria-label="71 reposts" class="social-embed-meta">🔁 71</span>
<time datetime="2024-08-09T17:51:12.198Z" itemprop="datePublished">17:51 - Fri 09 August 2024</time>
</a>
</footer>
</blockquote>
<link rel="stylesheet" type="text/css" href="data:text/css,%3Cstyle%3E…">
<script async src="https://example.com/embed.js"></script>
That ensures a full and semantic version of the post is included - even if the original site is unavailable or the user doesn't have JavaScript. If they do have JavaScript, it can be upgraded to the latest version of the post and the latest look & feel.
Thoughts?
Curtis Wilcox said on c.im:
@Edent
It feels wrong to have everything within <blockquote>.
I would use <section>, or even <article>, for the outermost element and <blockquote> for the actual post content, itemprop="articleBody", in your example; the rest is metadata about the quote.
I'm also "Team Outside" for whether <cite> should be in or out of <blockquote>.
BTW, the <img> in the articleBody is missing `alt`.
Curtis Wilcox said on c.im:
@Edent
The spec doesn't address this but does have an example where the <blockquote> is in a <figure> and the metadata is in <figcaption> (I don't think <figure> would be best as the outermost element for embedded social media posts).
In the post footer, I don't think the likes, replies, reposts should be inside link, only the timestamp.
https://html.spec.whatwg.org/multipage/grouping-content.html#the-blockquote-element
HTML Standard
More comments on Mastodon.