Do check for export first, since with browserify window is always defined and no module export is done