make ensure_loaded wait for page load