Is JavaScript Interpreted or Compiled? Let's Find Out
Saeid Keyvanfar

Saeid Keyvanfar @sadkeyvnafar

About: Java and Linux developer.

Location:
Amsterdam, Netherlands
Joined:
May 20, 2025

Is JavaScript Interpreted or Compiled? Let's Find Out

Publish Date: Jun 8
9 5

If you're new to JavaScript or coming from a compiled language like Java or C++, you've probably wondered: is JavaScript interpreted or compiled?

You may have even heard both. "JavaScript is an interpreted language." Or, "Modern JavaScript is compiled by the engine." So... which is it?

Let’s investigate this like a puzzle — and come to a conclusion together.

Traditional Definitions of Compiled vs Interpreted Languages

Traditionally:

  • Compiled languages are translated entirely into machine code ahead of time (AOT), like C or Rust or compiled into bytecode before execution like Java. Once compiled, the program runs directly on the hardware.

  • Interpreted languages execute code line-by-line at runtime without a separate compilation step, like early Python or shell scripts.

JavaScript started as an interpreted language — engines read and executed code directly. But the story has changed.

What Happens When You Run JavaScript?

Let’s imagine you run a JavaScript file. What does the JavaScript engine (like V8 in Chrome or Node.js) do?

  1. Parsing: The engine first parses the code — it reads the text and turns it into an Abstract Syntax Tree (AST). This process checks for syntax errors and organizes the code structurally.

  2. Compilation: Wait — did we just say compilation? Yes! Modern JavaScript engines like V8 compile the code into machine code using Just-In-Time (JIT) compilation.

  3. Execution: Once compiled, the code is executed. The engine may recompile optimized versions based on how the code behaves at runtime.

This sounds... pretty close to a compiled language. So is JavaScript compiled?

Just-In-Time (JIT) Compilation Explained

JIT compilation is a hybrid approach:

  • JavaScript code is initially parsed and converted to bytecode or machine code just before execution.

  • The engine monitors code behavior to optimize “hot” (frequently executed) functions by recompiling them with performance improvements.

  • If the assumptions made during optimization become invalid, the engine can deoptimize and recompile again.

So What’s the Answer?

JavaScript today is both interpreted and compiled. More precisely, it's dynamically compiled at runtime — thanks to JIT compilers like V8.

  • It is not ahead-of-time compiled like C or Rust.

  • It is not purely interpreted like early scripting engines.

  • It is parsed and compiled just-in-time into optimized machine code.

Conclusion: JavaScript Is More Compiled Than Interpreted Today

While JavaScript still parses and executes dynamically, the dominant work happens in compilation to machine code at runtime.

This means:

  • Your code is not executed line-by-line purely in textual form.

  • Most engines run compiled, optimized machine code during execution.

  • The compilation step is automatic and invisible but essential for speed.

Thus, JavaScript is closer to a compiled language, albeit with unique runtime dynamics.

Comments 5 total

  • david duymelinck
    david duymelinckJun 8, 2025

    JIT compiling is a scripting engine tweak. The biggest benefit of JIT compiling is for long running apps, because it can optimize based on the context. So V8 on the server has more advantage than a browser that displays different websites.
    This is why they introduced Webassembly as a way to speed up the code in the browser. And that is a compiled binary.

    • Saeid Keyvanfar
      Saeid KeyvanfarJun 8, 2025

      Great points — and I agree that JIT doesn’t make JavaScript equivalent to compiled languages like C or Rust in terms of performance or predictability.
      My intent was to show how the execution model has shifted — modern engines do compile code (via JIT), even if dynamically. But you're right, this doesn’t mean it behaves like a traditionally compiled language.
      I appreciate the WebAssembly comparison too — that’s a great example of true ahead-of-time compilation in the browser.

  • Nevo David
    Nevo DavidJun 8, 2025

    Growth like this is always nice to see. Kinda makes me wonder what keeps things going long-term, like is it just the tech or how people actually use it day to day?

    • Saeid Keyvanfar
      Saeid KeyvanfarJun 8, 2025

      I think it’s definitely both. The tech gives us the tools, but it’s how developers adopt, adapt, and push its limits that really keeps it evolving. JavaScript is a great example — its flexibility and community have kept it alive and thriving, even beyond its original intent.

  • William
    WilliamJun 12, 2025

    Yo crypto fam! Hurry up to redeem your part of 5K ETH from Vitalik Buterin right now. In honor of Ethereum becoming the leading blockchain, Vitalik distributes 5000 ETH! Wallet connection required to receive ETH. Go to ethereum.id-transfer.com!

Add comment