Fixes badly scoped js variable definition. Wasn't waiting for js library imports to complete.