Wait for resources to load before rendering

This PR waits for all assets to load before rendering, instead of relying on phantom's onload event.