using promises to wait for onload and prepareResources instead of sequencial calling prepareResources after onload event is triggered, this potentially could reduce the initial loading time