The later case (`} else if (typeof global === 'object' && typeof global.document === 'object') {`) works well. I'm not sure about how module.exports though… We could document that one must call modal.init() before using the modal in a Node / Browserify environment.