This should use `self` rather than `window` or it won't be usable in a Worker context.