Add browser checks so it can run in browserify/webpack environment