During the IR generation, the compiler makes changes in the source code that will allow the interpreter to generate a human-readable syntax. This syntax is very different from the machine-readable bytecode, and so the compiler has to work hard to translate it into machine code.
While the event loop is a great feature, it is important to understand that this is only a partial solution. There are other things that the JS engine can do to help improve performance and ensure that long-running tasks aren’t blocking the JS main thread.
Another thing that the JS engine can do is to offload long-running tasks to other threads on your browser or Node. These tasks can be anything from sending HTTP requests to listening for a response. When these things are spawned on separate threads, they aren’t blocked by the JS engine and can be handled much faster.
Generally, the JS engine will load and run your code in the order that it appears on the page. You should avoid placing your JS code before the HTML and CSS on your page because it may cause errors.