---
title: "Roll your own JavaScript runtime"
description: "A minimal JavaScript runtime called runjs can be built in Rust by combining the deno_core crate, which wraps a V8 isolate in a JsRuntime, with a single-threaded tokio runtime as the event loop."
url: "https://swe.quest/articles/roll-your-own-javascript-runtime-40ed853bc1965bed"
canonical: "https://deno.com/blog/roll-your-own-javascript-runtime"
source: "Deno"
published: "2022-07-29"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["runtimes","rust","javascript"]
---

# Roll your own JavaScript runtime

A post on [Deno](https://swe.quest/sources/deno.md), published 2022-07-29, 8 min read, How-to. Original: [https://deno.com/blog/roll-your-own-javascript-runtime](https://deno.com/blog/roll-your-own-javascript-runtime)

## Summary

A minimal JavaScript runtime called runjs can be built in Rust by combining the deno\_core crate, which wraps a V8 isolate in a JsRuntime, with a single-threaded tokio runtime as the event loop. The tutorial loads and evaluates ES modules from disk, adds a console API in a bundled runtime.js, and exposes async and sync filesystem functions to JavaScript via #\[op2\] ops registered through the extension! macro. deno\_core handles marshalling between JS Promises and Rust Futures, so each new native API needs only a small amount of glue code.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- Rust basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- JavaScript event loop ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- async Rust ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))

## Keywords

deno\_core, V8, tokio, Deno, JsRuntime

## Related posts

- [Roll your own JavaScript runtime, pt. 3](https://swe.quest/articles/roll-your-own-javascript-runtime-pt-3-dea9fc6d84e2ecd0.md): Deno · 2023-05-04 · Medium · 4 min read · Runtimes & VMs, Rust, JavaScript, Performance engineering
  V8 startup snapshots can speed up launch of a custom deno\_core-based JavaScript runtime at a typically negligible cost in binary size.
- [Roll your own JavaScript runtime, pt. 2](https://swe.quest/articles/roll-your-own-javascript-runtime-pt-2-53cebea56dc325e0.md): Deno · 2023-02-15 · Medium · 7 min read · Runtimes & VMs, Rust, JavaScript, TypeScript
  A custom JavaScript runtime built on deno\_core gains three capabilities: a fetch op backed by the reqwest crate and registered in the runjs extension, a CLI that takes the script path as its first argument, and TypeScript/TSX support.
- [Deno's Other Open Source Projects](https://swe.quest/articles/deno-s-other-open-source-projects-d23e8b3569399530.md): Deno · 2025-10-16 · Easy · 7 min read · Open source, Rust, Runtimes & VMs, JavaScript, Developer tools
  Deno publishes many MIT-licensed supporting libraries extracted from its runtime, most of them Rust crates.
- [Wrapping My Mind Around Node.js Runtimes](https://swe.quest/articles/wrapping-my-mind-around-node-js-runtimes-e02012f26cbbaf25.md): Neon · 2024-09-18 · Easy · 8 min read · JavaScript, Runtimes & VMs, TypeScript
  Deno and Bun take different approaches to replacing Node.js as a server-side JavaScript runtime.
- [Deno 1.20 Release Notes](https://swe.quest/articles/deno-1-20-release-notes-bca0b4c539f63df8.md): Deno · 2022-03-17 · Medium · 12 min read · JavaScript, Runtimes & VMs, Performance engineering, Developer tools, Rust
  Deno 1.20 cuts JavaScript-to-Rust op call overhead by up to ~60% by using Rust proc macros to generate a dedicated V8 binding per op, eliminating op routing and skipping deserialization of unused arguments; a 1 MB base64 roundtrip drops from ~125 ms to ~3.3 ms. The release also adds automatic gzip/brotli compression of non-streamed HTTP responses, an unstable \`deno bench\` subcommand (1000 warmup plus 1000 measured iterations by default), and a cross-platform \`deno task\` runner using a POSIX-like shell subset.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
