fix issue when window is undefined. (server side require)

There may be some cases, when window object is not defined. I faced this problem when tried to prerender reactjs components on the server.