Do all the long work in the separate scripts and use AJAX to load the needed content, you may also break the loading part into pieces.
jQuery.get
is an easiest way to start http://api.jquery.com/jQuery.get/
The example code will load the data into the element having id=result
(of course you need to include jQuery http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery)
$.get('long_script.php', function(data) {
$('#result').html(data);
});
Of course, this is a bit harder then just echoing the results in the loop, but this is guaranteed to work on any server/browser setup and also the whole page is loaded during the long task, not anyhow limiting you in html/css usage