Callback after twttr.widgets.load processes tweets on the page

@mitar_m Mitar

I am loading new and new tweets dynamically on the page (infinite scrolling) and I am calling twttr.widgets.load each time I add new tweets for them to be rendered Twitter-like. Is there a way to get some callback/event once they (or each separately) have been processed so that I could do some additional things once they have whole content and size (like reflowing them on the site)?

1 year 18 weeks ago


@benward Ben Ward

There's nothing like that just yet, I'm afraid, but that's a nice addition to make. I'll take a look into it.

For now, you might get some milage by watching for DOM mutation events in newer browsers (although that whole API is unstable and being replaced in DOM4, so ymmv), but our initialization code will run replaceChild on all the embed codes with their iframe replacements, so you might be able to use it still.

As I say, we'll look into giving you a proper callback interface soon.

1 year 18 weeks ago
@mitar_m Mitar

Yes, watching DOM changes is ... ugly. At least for now. I will wait for better interface. Thanks! You are really great and responsive.

1 year 18 weeks ago
@mitar_m Mitar

Ah, one more thing. It would be great if callback would get information if tweet existed. Currently, I cache html fragment for the tweet and then call twttr.widgets.load over those fragments. If tweet was deleted in meantime, fragment is left as it is. It would be useful to get this information in callback so that I can decide what to do (probably simple remove the tweet and inform the server to check).

1 year 18 weeks ago
@mitar_m Mitar

Or even better. As Twitter library fetches data about tweets from the server, this data could be passed to the callback. If data would be missing, this means tweet was deleted. If data would be there, developer could use this for example to provide a feedback for current number of retweets (for example, add some CSS to show more popular tweets).

1 year 18 weeks ago
@mitar_m Mitar

Any followup?

1 year 13 weeks ago
@seagyn Seagyn Davis

+1 on this.

43 weeks 6 days ago
@Kenjamin Ken Caron

+1 Would love to see this too

27 weeks 3 days ago
@BoolaDev Bula


25 weeks 13 hours ago
@pepsilike Viktor Davidovich


24 weeks 2 days ago
@MrLugh Elordi Gastón Ariel

Hey guys! Any progress about calling a callback after tweets are loaded?

17 weeks 4 days ago

I ended up loaded tweets 'dynamically' from my own database so in that instance, callbacks are your own responsibility, this can also cut down on twitter calls, but is slightly less than 'real-time'.

After a year and 5 days, this probably won't be resolved helpfully anytime soon...

good luck!

17 weeks 3 days ago
@bartknows Bartosz

+1 for this...

15 weeks 4 days ago
@anirban_dutta_ Anirban Dutta

Hi, I have a problem where the Twitter widget gets hidden because my website cannot handle the tags correctly. I dont know if the problem is related so forgive my posting it here, in case it isn't.
The Dev team has suggested using the window.parent.jQuery(resizeMe); within the iframe, so the embedable timeline widget looks like:
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);;js.src="//";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");window.parent.jQuery(resizeMe);

However it does not work because the resizeMe callback must be called after twitter gets finished with it's execution (and sets the size), within the iframe. They said " For this, you must set up the twitter feed to make the callback after it is loaded. Typically this is done by using the ready function." - Has anyone faced this problem? Any idea how to make this work?

15 weeks 1 day ago
@sduncombe Scott Riker Duncombe

How I solved this - use DOMNodeInserted or DomNodeRemoved events.

JS Fiddle:

12 weeks 4 days ago
@mitar_m Mitar

Those events are deprecated.

12 weeks 4 days ago