use window and module exports. remove defer.