DEV Community

Cover image for Quick Overview To JavaScript Engines
Pato
Pato

Posted on • Edited on

17 6

Quick Overview To JavaScript Engines

You don't need to know how the JavaScript engines work in order to learn JavaScript but it's always good to learn how things work under the hood.

Keep in mind that every JavaScript gets interpreted differently depending on what engine your browser is using.

JavaScript parsing: This means that your browser reads your javascript code.

JavaScript execution: This is the actual process where our code does something.

When the code is parsed and executed that is when the browsers makes use of the JavaScript engine.

The engine for Google Chrome is called v8, and the one for Firebox its called SpiderMonkey.

For more info on:
Google V8
Firebox SpiderMonkey

Typically the engines have two parts:

-The Interpreter
-The Compiler (Usually a just-in-time compiler) aka JiT

Note: In this post, we will focus on how the engines generally work, not what the engines do when the code executes.

The Interpreter

This is where our engine parses/loads our script (JavaScript code), reads it, then translates it to byte code, and finally starts the execution. The byte code is giving to the compiler.

The Compiler

Compiles your script into machine code. So the translation from JavaScript code to machine code is what our compiler does.

Remember: that just-in-time compilation means that our compiler starts compiling and executing the compiled code.

JavaScript Engine Does Optimization

If you wrote a script and then modified part of it, the JavaScript engine checks what code didn't change between the last execution and the one that is currently running. The current version not always gets re-compiled. The engine checks what code has been compiled and doesn't compile it again, which makes the engine's process faster.

Browser APIs

Our browsers come with default functions or objects that work with our JavaScript code. When we make use of this functions or objects that are in our browser APIs, the engine interprets and compiles our code then the browser knows where are these functions or objects coming are from.

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (1)

Collapse
 
huylong profile image
huylong

Thank you

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay