Jorge I always do it like this in php. But for example if i have a div that takes like 10 seconds to load and i write an if statement your saying that it will be faster if is false? or it will take 10 seconds anyways? .. dont know if u understand i speak mainly spanish.. Also how to do a spinner (or a "Loading...") and dont show the div until all div content is loaded
So I assume you have a button on the page to start some process. At that time, show the spinner and start the load process. With the example I gave you above, hide the spinner during the callback phase.
I'd recommend you take a look at this js spinner rather than using an animated gif. I use this in all my projects now.