Skip to content

andriyl/js-deep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

JS-Deep

JS-Deep — a deep guide to JavaScript as an embedded execution layer in various hosts (Node.js, browsers, Electron, databases).
This resource is aimed at students, developers, and enthusiasts who want to go beyond basic tutorials and understand JS engines, host interaction, API bindings, and execution context.


Overview

JavaScript always runs inside a host (browser, Node.js, Electron, database). Layers :

  • JS – user scripts, functions, variables, libraries
  • Engine – parsing, JIT compilation, garbage collection (V8, QuickJS, SpiderMonkey)
  • Host – context, API bindings, sandbox, access to filesystem, network, DOM

Components

Component Description Responsibilities Does Not Do
JavaScript (JS) Code, ECMAScript Logic, computations, calls host API Access OS, FS, network
JS Engine V8, SpiderMonkey, QuickJS Parsing, JIT, execution, GC Provides host API
Host Browser, Node.js, Electron, Database Context, API, sandbox, control execution Executes JS by itself

flowchart TB

    subgraph Layer_JS [JS Layer]
        direction TB
        JS["JavaScript Code(user code, libraries)"]
    end

    subgraph Layer_Engine [Engine Layer]
        direction TB
        Realm["Realm(global object + built-ins)"]
        Engine["JS Engine(V8 / QuickJS / SpiderMonkey)"]
        Stack["Call Stack"]
    end

    subgraph Layer_Host [Host Layer]
        direction TB
        Hooks["Host Hooks(engine ↔ host boundary)"]
        API["Host APIs(fetch, fs, timers, DOM)"]
        Loop["Event Loop"]
        Queue["Task / Microtask Queues"]
        Sandbox["Security / Sandbox"]
        HostApp["Host Application(browser / node / deno)"]
    end

    JS --> Realm
    Realm --> Engine
    Engine --> Stack
    Stack --> Hooks
    Hooks --> API
    API --> Loop
    Loop --> Queue
    Queue --> Stack
    API --> Sandbox
    Sandbox --> HostApp
Loading

Realm

A Realm is an isolated JavaScript environment that contains:

  • a global object
  • intrinsic objects (Array, Object, Promise, etc.)
  • execution contexts

Each Realm has its own set of built-ins.

Examples of separate realms:

  • Browser window
  • iframe
  • Web Worker
  • Node.js vm context

Runtime (Logical Boundary)

Runtime is a conceptual boundary combining Engine and Host.

JS always runs inside a runtime environment.

flowchart TB
    subgraph Runtime["JavaScript Runtime"]
        direction TB
        Engine["JS Engine (V8 / QuickJS / SpiderMonkey)"]
        Host["Host Environment (Browser, Node.js, Electron, etc.)"]
    end
Loading

References

Goals

  • Provide a clear mental model of JavaScript as an embedded execution layer
  • Distinguish responsibilities between JavaScript, the JS Engine, and the Host
  • Explain how API bindings and native bridges connect JS to host resources
  • Demonstrate simplified embedding pseudocode examples
  • Encourage deeper exploration of engine internals and runtime architecture

About

Deep guide to JavaScript internals, embedding, host architecture and practical embedding examples.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors