Made it compatible with web workers

window does not exist in worker scope. removed any referenes to it.