Published at
Updated at
Reading time

The following news is wild!

Twitter changed how its library widgets.js handles deleted Tweets embedded on other sites. I never considered this interesting case. How would one build a UI library for data that's not available anymore?

I'd have to sleep over this problem, but here's what I wouldn't do, aka the new Twitter way. ๐Ÿคฆโ€โ™‚๏ธ

Twitter decided that it's reasonable to wipe out embedded Tweet content on millions of sites if the Tweet in question isn't available on their platform anymore. ๐Ÿ˜ฒ

Kevin Marks shares this discovery in detail on his blog. Here's a quick summary for my archive.

widgets.js behavior so far

If you decide to embed a Tweet and hit the embed button in the Twitter UI, you'll receive a snippet like the following.

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">
   This is worth checking out on GitHub. ๐Ÿ‘ <a href="TWEET_RESOURCE"></a></p> &mdash; Stefan Judis (@stefanjudis) <a href="TWEET_URL">April 9, 2022</a>
<script async src="" charset="utf-8"></script>

You include the content in a blockquote, load Twitter's UI script and when it kicks in, the existing markup and content is enhanced with the usual Twitter look'n'feel.

Progressive enhancement for the win! Sweet!

Explanation showing what happens with an embedded Tweet once widgets.js is executed.

This approach works great for available Tweets. And if the embedded Tweet was deleted, widgets.js wouldn't do anything. It would leave your fallback content untouched.

It's your content on your site, right?

widgets.js new behavior

The case of Tweet deletion is where Twitter's recent changes come in. If one of your embedded Tweets was deleted, widgets.js will now wipe out the fallback HTML and render an empty shell.

Think this through for a moment; Twitter decided that if the content isn't available on their platform anymore, it shouldn't be on your site either.

Excuse me?

An empty Tweet that only includes loading bars.

This change is beyond wild. Twitter is now messing with the quotes on millions of pages.

But on the bright side, we can learn one thing from this.

Own your content! You'll never know if a service will be around tomorrow or, in some rare cases, if it decides to mess with your HTML and delete quotes all around the internet.

Let's hope Twitter reverts this change. ๐Ÿคž Check Kevin's post if you want to dive deeper into it!

Was this post helpful?
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 4 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles