If hash computation in Javascript is a crucial bottleneck, there are better choices than SHA1-- like BLAKE2s, which is designed to be fast on 32-bit platforms.
If collisions aren't a huge concern, something like SipHash is also possible.
https://blake2.net/
https://github.com/dchest/blake2s-js
https://131002.net/siphash/