Using the ash function detection "ready", I needed to add some kind of poll so that I would only delete the download message if any downloadable tweets are loading. To verify this, I will add the following to my hosts file to simulate an error receiving tweets:
127.0.0.1 api.twitter.com
Please note that my survey is performed 10 times with an interval of 200 ms. This is because I don't want the code to poll indefinitely when the tweets seem to load in the first 2 seconds (if they download at all). You can adapt these values ββto suit your situation.
function pollForTweets() { if (jQuery("div#twitter-feed").find("div.twtr-tweet").length > 0) { jQuery("div#twitter-load").remove(); return; } pollForTweets.pollCounter = pollForTweets.pollCounter || 0; if (pollForTweets.pollCounter < 10) { pollForTweets.pollCounter++; setTimeout('pollForTweets()', 200); } } new TWTR.Widget({ id: 'twitter-feed', version: 2, . . . features: { scrollbar: false, loop: false, live: false, behavior: 'all' }, ready: function () { pollForTweets(); } }).render().setUser('twitter').start();
Brian hinchey
source share