jQuery.fn.exists = function() { return jQuery(this).length > 0; }; updateFeed = function (twitter_feed) { var uniq = new Date; var unixtime_ms = uniq.getTime(); $.get( '/ajax/twitter_live/index.php?twitter_feed=' + twitter_feed, { no_cache: unixtime_ms }, function (result) { $('.external-twitterlist').html(result); }, 'html'); setTimeout(function() { updateFeed(twitter_feed); }, 60000); }; $(document).ready(function () { if ($('.twitter_feed').exists()) { var twitter_feed = $('.twitter_feed').text(); setTimeout(function() { updateFeed(twitter_feed); }, 60000); } });