We should throw this in a separate module that is webworker-safe and supports a better RAF polyfill (@benjamn has a good one)