The second solution you mention is fine until you've refactored it to use requirejs.

Everything's easier to test when it's defined in the global namespace, but that doesn't mean we should define everything in the global namespace. Sorry, that argument doesn't stick.