New Feature: Lazy Loading of Embedded Tweets

LGF • Views: 20,551

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: 2016-01-01 10:29 am PST
LGF User's Guide RSS Feeds Tweet

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
Square Cash Shop at amazon
as an LGF Associate!
Recent PagesClick to refresh
Political Extremism: Cambridge U Study Shows Psychological Profile of Extremists Cambridge University in the UK did a study on whether there is a common psychological denominator to civil unrest, and Hoo Boy, does THIS ever sound familiar: Psychologists are now asking what turns the civil discord common in partisan ...
Khal Wimpo (exhaling for 1st time in 4 yrs)
13 hours, 52 minutes ago
Views: 160 • Comments: 0 • Rating: 1
Tweets: 7 •
Tomorrow - Jimmy Wahlsteen, Vincent VegaProvided to YouTube by Epidemic Sound Tomorrow · Jimmy Wahlsteen · Vincent Vega Epidemic Presents: Crates (M. Bison Edition) ℗ Epidemic Sound Released on: 2020-03-13 Producer: Kasper LindgrenComposer: Jimmy Wahlsteen Auto-generated by YouTube.
Thanos
1 day, 8 hours ago
Views: 234 • Comments: 0 • Rating: 0
Tweets: 2 •
#Thegreatpoolpondconversion - 210221The waterfall bilge pump died three weeks ago.We're trying something new.Saturday we test installed two tiny aquarium pumps to get the waterfall going again.These pumps are very small but are designed to run all the time. Bilge pumps aren't. Though ...
Dangerman
1 day, 12 hours ago
Views: 255 • Comments: 0 • Rating: 3
Tweets: 0 •
The Staves - Best Friend [Live at Lafayette] The Staves - Best Friend [Live at Lafayette] Our new album 'Good Woman' is out now: lnk.to Follow The Staves:Facebook thestaves.lnk.toTwitter thestaves.lnk.toInstagram thestaves.lnk.to YouTube thestaves.lnk.toSpotify thestaves.lnk.toiTunes thestaves.lnk.to When I could be anythingThat I wanted OhWe could be better thanBetter ...
Thanos
5 days, 1 hour ago
Views: 697 • Comments: 0 • Rating: 0
Tweets: 1 •
Sting - Shape of My Heart (Official Music Video)REMASTERED IN HD!Official Video For Sting's "Shape Of My Heart".#Sting #ShapeOfMyHeart #Remastered
Thanos
5 days, 6 hours ago
Views: 812 • Comments: 0 • Rating: 0
Tweets: 0 •
Amy Macdonald - Statues (Single Mix) (Official Audio) One of Amy's best features is that she doesn't "Americanize" her singing voice, something too many UK performers do. The Official Audio for Statues (Single Mix) by Amy Macdonald, taken from the new album 'The Human Demands'. Listen now: ...
Thanos
5 days, 7 hours ago
Views: 823 • Comments: 0 • Rating: 0
Tweets: 1 •
KALEO - Break My Baby (LIVE From Þrídrangar, Iceland) Break My Baby - Live from Þrídrangar - Iceland Music and Lyrics by JJ Julius Son Stream/Download: kaleo.lnk.to Þrídrangar means “three rock pillars” and is located 4.5 miles from Iceland's south coast. In 1939, three of Westman Islands' best ...
Thanos
1 week, 4 days ago
Views: 1,587 • Comments: 0 • Rating: 0
Tweets: 6 •
Lake Street Dive - Hypotheticals [From Phantom Studios] Video Directed + Produced by Alex Chaloff for Bucket's Moving CompanyRecorded at Phantom Studios, Gallatin TN"Hypotheticals" from the upcoming Lake Street Dive album ObviouslyOut March 12th on Nonesuch RecordsPre-Order Obviously NOW: smarturl.it Produced by Mike ElizondoRachael Price: vocalsMike “McDuck” ...
Thanos
1 week, 4 days ago
Views: 1,348 • Comments: 0 • Rating: 0
Tweets: 4 •
Jon Batiste - CRY (Lyric Video) Listen to “CRY” and order my album ‘WE ARE’: jon-batiste.lnk.to Shop merch: jonbatistestore.com Follow Jon:Instagram: jon-batiste.lnk.toFacebook: jon-batiste.lnk.toTwitter: jon-batiste.lnk.toSpotify: jon-batiste.lnk.to Apple Music: jon-batiste.lnk.toAmazon: jon-batiste.lnk.toSoundcloud: jon-batiste.lnk.toPandora: jon-batiste.lnk.toYouTube Music: jon-batiste.lnk.to Official Website: jonbatiste.com Video Credits:Director: Charles ToddDirector of Photography: Ben CareyProducer: Brian ...
Thanos
1 week, 4 days ago
Views: 1,746 • Comments: 0 • Rating: 0
Tweets: 5 •
Robert Fripp & Peter Gabriel - Here Comes the Flood (1979) [RV VERSION] Robert Fripp & Peter Gabriel - Here Comes The Flood (1979) [RV VERSION] #Peter gabriel robert fripp here comes the flood#Robert fripp peter gabriel flood#robert fripp peter gabriel flood#gabriel fripp here comes the floodhere comes the flood#Fripp#Peter#Gabriel#robert fripp#King crimson ...
Thanos
1 week, 4 days ago
Views: 1,440 • Comments: 0 • Rating: 2
Tweets: 6 •