Enable client-side use

Enabled client-side by adding to the global window object instead of module.exports.

Wrapped code in an IIFE to prevent leaking to global scope in the browser.