Updated JS to be used in the browser

Added a closure which accepts an exports object as an argument.