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


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)?


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.


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


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).


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).


Any followup?


+1 on this.


+1 Would love to see this too






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


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!


+1 for this…


Hi, I have a problem where the Twitter widget gets hidden because my website cannot handle the within the iframe, so the embedable timeline widget looks like:

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?


How I solved this - use DOMNodeInserted or DomNodeRemoved events.

JS Fiddle:


Those events are deprecated.


+1 for this feature, too :slight_smile:


Hi everyone. Since this thread happened we added two new events. Use‘rendered’, ƒ) to get an event for every individual widget that renders in a page, or‘loaded’, ƒ) for the whole set after you call twttr.widgets.load.

See the [node:25877, title=“scripting events documentation”] for more details.



Thanks, Ben!


can you please post your code for this? i’m trying to do the same thing…