See asm.js. This is exactly what you propose.
BTW, asm.js has been superseded by Webassembly which ditches Javascript completely.
BTW, asm.js has been superseded by Webassembly which ditches Javascript completely.
Not sure if I understood it correctly though.
The browser, instead of downloading javascript, downloads WASM bytecode, and this bytecode gets compiled ahead-of-time to machine language and ran by the browser.
The bytecode itself is the product of compiling a source code written in the language of your choice, for example Java or something more advanced like INTERCAL.