New Feature: Lazy Loading of Embedded Tweets

LGF • Views: 30,253

We’ve been getting a lot of reports here at Lizard Central that LGF members were having crashing problems in the longer comment threads, and after a lot of head-scritching and puzzlement I finally narrowed down the cause to… the embedded tweets.

Twitter’s embedded tweets work like this; when you post the URL of a tweet in a comment, our code calls Twitter’s API and gets a special block of HTML code that includes the text of the tweet, the author’s info, and its creation time. This HTML code is what first appears in a comment; it’s the “un-rendered” version of the tweet.

Once this HTML is placed in a web page, Twitter’s Javascript code (loaded in a file named widgets.js) finds those special blocks of HTML and transforms (or “renders”) them with the Twitter look, and with images, videos, etc.

But Twitter has been messing around with their code for rendering embedded tweets lately, and while it has expanded some of their functionality, the downside is they’ve been getting slower and slower to load. I investigated a bit, and discovered each rendered tweet is now loading no fewer than EIGHT external Javascript files, which probably explains a lot of the slowdown.

All of which leads us to the new feature.

When a page of comments loads now, instead of going through all of them and rendering them, our code stops that automatic rendering and leaves the tweets in their initial “un-rendered” text-only state.

And to let you see the actual fully rendered tweet, a button (that looks like a recycling symbol) is added to our blue action bar beneath the tweet. Click it and the tweet will be rendered by Twitter’s code, which works fast enough when it’s only doing one at a time.

And there’s actually a big advantage to this new approach; long comment threads now finish loading a whole lot faster, and people with limited memory devices like phones and tablets should be able to participate in much longer threads than before.

If you’re using a desktop computer and don’t have any crashing issues with pages full of embedded tweets, you can set it to always show embedded tweets with the checkbox at the top right of the comments.

Jump to top

Create a PageThis is the LGF Pages posting bookmarklet. To use it, drag this button to your browser's bookmark bar, and title it 'LGF Pages' (or whatever you like). Then browse to a site you want to post, select some text on the page to use for a quote, click the bookmarklet, and the Pages posting window will appear with the title, text, and any embedded video or audio files already filled in, ready to go.
Or... you can just click this button to open the Pages posting window right away.
Last updated: 2023-04-04 11:11 am PDT
LGF User's Guide RSS Feeds

Help support Little Green Footballs!

Subscribe now for ad-free access!Register and sign in to a free LGF account before subscribing, and your ad-free access will be automatically enabled.

Donate with
PayPal
Cash.app
Recent PagesClick to refresh