I don't follow the explanation of why this needs to be global. Can you point to particular lines of code that would work for a local instance loaded after the html is loaded onto the page?