use global window object if present (restores compatibility with browserify)