---
title: "Bringing Javascript to WebAssembly for Shopify Functions"
description: "Shopify runs JavaScript in Shopify Functions by compiling the QuickJS interpreter to WebAssembly/WASI via Javy."
url: "https://swe.quest/articles/bringing-javascript-to-webassembly-for-shopify-functions-80a81868faf1489b"
canonical: "https://shopify.engineering/javascript-in-webassembly-for-shopify-functions"
source: "Shopify Engineering"
published: "2023-02-09"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 16
tags: ["webassembly","javascript","runtimes","rust","serverless"]
---

# Bringing Javascript to WebAssembly for Shopify Functions

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2023-02-09, 16 min read, Deep dive. Original: [https://shopify.engineering/javascript-in-webassembly-for-shopify-functions](https://shopify.engineering/javascript-in-webassembly-for-shopify-functions)

## Summary

Shopify runs JavaScript in Shopify Functions by compiling the QuickJS interpreter to WebAssembly/WASI via Javy. JIT engines like V8 can't run inside Wasm, so QuickJS fills the gap. Embedding the engine with the user's bytecode produced modules of 800KB or more, well over the 256KB limit. Shopify got around this with an ad-hoc dynamic linking scheme built on Wasmtime's linker: a shared "javy\_quickjs\_provider\_v1" library exposes realloc and eval\_bytecode, so each function shrinks to a roughly 220-byte stub plus its bytecode, and the engine can be precompiled and patched centrally. The minimal Javy runtime adds POSIX-like stdin/stdout APIs on a Javy global and a Rust-implemented UTF-8 TextEncoder/TextDecoder, but does not yet enable the event loop.

Written by swe.quest, not by the author.

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

## Topics

- [WebAssembly](https://swe.quest/tags/webassembly.md) (Languages)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Serverless](https://swe.quest/tags/serverless.md) (Backend & APIs)

## Prerequisites

- WebAssembly basics ([easy posts on WebAssembly](https://swe.quest/tags/webassembly.md?difficulty=easy))
- WASI
- JavaScript engines ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

Shopify Functions, Javy, QuickJS, Wasmtime, Wizer, WASI, WinterCG, Component Model

## Related posts

- [Why is WebAssembly a second-class language on the web?](https://swe.quest/articles/why-is-webassembly-a-second-class-language-on-the-web-36ba94a05082ce89.md): Mozilla Hacks · 2026-02-26 · Medium · 13 min read · WebAssembly, Browsers, Language design, Performance engineering
  WebAssembly remains second-class on the web because it can only load code and reach Web APIs through JavaScript.
- [Introducing the WebAssembly JavaScript Promise Integration API](https://swe.quest/articles/introducing-the-webassembly-javascript-promise-integration-api-b17a598677f4452f.md): V8 · 2024-07-01 · Medium · 11 min read · WebAssembly, JavaScript, C & C++, Browsers, Concurrency
  JSPI lets WebAssembly code written against synchronous APIs call asynchronous Web APIs.
- [WebAssembly JSPI has a new API](https://swe.quest/articles/webassembly-jspi-has-a-new-api-8f87900c3d9ad3d8.md): V8 · 2024-06-04 · Medium · 6 min read · WebAssembly, Browsers, Concurrency, Runtimes & VMs
  WebAssembly JavaScript Promise Integration (JSPI) ships a revised API in Chrome M126 that drops explicit Suspender objects and instead uses the most recent JS-to-Wasm export call as the suspension cut point.
- [Four Approaches to Debugging Server-side WebAssembly](https://swe.quest/articles/four-approaches-to-debugging-server-side-webassembly-70e30fb86ae05146.md): Shopify Engineering · 2022-09-07 · Medium · 8 min read · WebAssembly, Debugging, Developer tools, Rust
  Step-debugging server-side WebAssembly can be done four ways: compiling to a native target and using LLDB/GDB, running the Wasm under Wasmtime inside LLDB, using a Wasm-specific debugger like Wasminspect, or using browser DevTools via Chrome's DWARF extension or source maps.
- [Introducing Ruvy](https://swe.quest/articles/introducing-ruvy-a780cb3b4891bef0.md): Shopify Engineering · 2023-10-18 · Medium · 5 min read · WebAssembly, Ruby, Performance engineering, Open source
  Ruvy is an open-source toolchain built on ruby.wasm that compiles Ruby scripts into WebAssembly modules, pre-initializing the Ruby VM and preloaded Ruby files at build time instead of at startup.

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)
