As others have pointed out, there are various ECMAScript mechanisms , and some of them use the JIT (Just-In-Time) compiler , while some others use runtime interpreters , being the first preferred option for most browsers at present, as this gives some performance advantages over the last option.
You can see another question about this: https://softwareengineering.stackexchange.com/questions/138521/is-javascript-interpreted-by-design
For example, V8 is the JavaScript engine used in Google Chrome, node.js , and can also be embedded in C ++ applications.
About your idea of ββsending compiled or precompiled code for the client instead of raw JS, there are some projects working on something similar:
Asm.js consists of a strict subset of JavaScript into which code written in statically typed languages ββwith manual memory management (e.g. C) is converted using a source-source-compiler such as Emscripten (based on LLVM ). Performance is improved by limiting language features to those that are amenable to ahead-of-time optimization and other performance improvements.
An important fact related to Asm.js is that existing JavaScript engines work well with its code style, so you can start using it right away! But the code that it produces is still (a subset ) of JS, which we know but is written in some way, which helps JS machines work faster:

Of course, there are also many limitations on what you can do with it, since it is mainly focused on working with just numbers . See http://ejohn.org/blog/asmjs-javascript-compile-target/
Actual support for Asm.js is still a limitation, so you cannot use things like "use asm" , and although you can run Asm.js code on today's browsers and get some performance improvements, it will not be as good as it could be in browsers that could optimize Asm.js code . However, we can start with this and some other improvements in the (hopefully close) future. See https://blog.mozilla.org/research/2015/02/23/the-emterpreter-run-code-before-it-can-be-parsed/
Meanwhile, and for a more general JS goal that should work with more than just numbers, you can use the Google Closure Compiler . I would recommend looking at the FAQ first , and then you can start playing the online tool with it .