I'm pretty sure someone already compiled Linux to asm.js a few years ago. As asm.js is/was a subset of JS, you could say it's already been done. In theory, you could continue work from there in JS.

https://medium.com/@retrage/lkl-js-running-linux-kernel-on-j...