Fix loading race condition in widget script