Shopify Functions in JavaScript: When You Can Skip Rust for Discounts, Shipping and Payment Customisations
Shopify Functions in JavaScript are production-ready, but Shopify still recommends Rust. Here is when the performance gap matters and when it does not.
date
You need custom checkout logic. A tiered trade discount, a shipping rule that hides next-day delivery for bulky items, a payment method that only appears for approved wholesale accounts. Shopify Scripts used to handle this in Ruby. Now it is Shopify Functions, and the first question any developer asks is whether to write them in JavaScript or Rust.
Shopify's own documentation pushes Rust. Third-party blogs claim JavaScript only reached general availability in Winter '26, or that Rust is being phased out. Neither claim holds up. This article sets out what Shopify actually says, how Shopify Functions in JavaScript are compiled and run, and a practical way to choose a language for a real build.
What Shopify actually says about JavaScript for Shopify Functions
JavaScript has been a supported production language for Shopify Functions for some time. Shopify's developer changelog entry announcing it is unambiguous: functions written in JavaScript can be deployed to production, and "going forward Rust and JavaScript will be our first-class languages". Any other language that compiles to WebAssembly, such as AssemblyScript or TinyGo, also works if the output meets Shopify's requirements.
At the same time, the Shopify Functions documentation still describes Rust as "recommended and strongly preferred" and as the most performant option. Both things are true at once. JavaScript is fully supported. Rust is faster. Nothing in Shopify's changelog, as of our check in November 2026, deprecates Rust or announces a new GA milestone for JavaScript. Treat posts that say otherwise as noise.
How JavaScript becomes WebAssembly: the Javy compile path
Shopify Functions run as WebAssembly modules inside Shopify's checkout infrastructure. Rust compiles straight to WebAssembly. JavaScript cannot, so Shopify built a toolchain called Javy, now hosted by the Bytecode Alliance. When you run a build through Shopify CLI, Javy embeds the QuickJS engine, translates your JavaScript into QuickJS bytecode, and uses a tool called Wizer to snapshot the initialised module. That snapshot is what gets deployed, so there is no engine start-up cost at run time.
The practical implications for a build are these:
- Your code is interpreted, not compiled. The QuickJS engine inside the module reads your bytecode at run time. Every line costs several times more WebAssembly instructions than the equivalent Rust.It is plain ECMAScript 2020. Javy does not provide Node or CommonJS APIs. No file system, no network, no Node crypto. A function is a pure transformation: JSON input in, JSON output out.The CLI version matters. Javy is bundled with Shopify CLI, and a dependency update in one CLI release pushed some developers' module sizes over the limit until a later release shrank them again. Pin your CLI version in CI and check the compiled module size on every deploy.TypeScript is fine. Shopify CLI handles the TypeScript step before Javy runs, so you get types and a familiar workflow.
The three limits that decide Shopify Functions JavaScript vs Rust
The language debate is really a debate about three hard limits that Shopify enforces on every function run:
- 11 million WebAssembly instructions per run for carts of up to 200 line items. The budget scales up for larger carts. Exceed it and the function fails for that checkout.256KB maximum module size. This is the compiled WebAssembly file, including the embedded engine for JavaScript builds.128kB maximum input size, raised from 64kB in December 2024. This is the JSON your function receives from the cart or checkout.
Shopify's guide to optimising instruction counts gives a concrete comparison. One of its Cart Transform examples runs at 57,664 instructions in Rust and 386,480 in JavaScript. That is a gap of roughly six to seven times. Shopify narrowed it in September 2024, when Javy 3.1 shipped with CLI 3.67 and made JavaScript functions around 40% faster, but the interpreter overhead has not gone away.
When the performance gap matters, and when it does not
Here is the point that most comparison posts miss. The instruction budget is per execution, not per day. A function that runs comfortably on one checkout runs just as comfortably on ten thousand. Your store's traffic has no bearing on whether a JavaScript function fits inside the limit.
The instruction budget is per checkout run, not per day. How busy your store is has nothing to do with whether a JavaScript function fits.What does change the calculation is the shape of the work inside a single run. A typical discount function for a direct-to-consumer store does a handful of lookups and some arithmetic across a cart of three to eight lines. Measured in JavaScript, that lands in the low hundreds of thousands of instructions, a small fraction of the 11 million available. Rust would be faster, and nobody would ever notice.
The gap starts to matter in specific situations:
- Large carts. B2B and wholesale orders with 100 or more lines multiply every loop. Nested loops over lines, tiers and rules grow fast.Heavy parsing. Reading large JSON metafields or, since API version 2026-04, metaobject entries, and walking them line by line in an interpreter.Cryptography or hashing. Shopify staff have told developers directly that Javy cannot fit crypto work within the instruction limits, and to use Rust for it.Complex Cart Transform logic. Bundling, splitting and re-pricing many lines in one pass is the most expensive category of function.
The failure mode is quiet. When a function exceeds its budget, Shopify records an error in the function run logs and the checkout proceeds without the discount, the shipping rule or the payment filter. The customer sees a higher price or a missing option and leaves. Nobody files a bug report. This is a conversion problem dressed up as an engineering one, and it is why we look at function logs during a conversion rate optimisation audit.
A decision framework for a client build
This is how we decide at the start of a Shopify app development project. It takes a day of prototyping, not a week of debate.
- Default to TypeScript. If the logic is lookups, comparisons and arithmetic, and the merchant's typical cart is under 50 lines, start in JavaScript. The team that maintains it in 18 months will almost certainly know JavaScript. In the Scottish and wider UK market, Rust developers are scarce and cost more.Measure before you decide. Run the function locally against a fixture of your worst realistic cart, not your average one. For a B2B store that means the biggest order of the last 12 months. Shopify CLI reports the instruction count on every local run. If the worst case sits under three to four million, you have headroom and you ship it.Move to Rust when the numbers say so. Carts routinely over 100 lines, crypto, complex allocation across many lines, or a compiled module creeping towards 256KB are all reasons to rewrite. Rust is not harder to deploy, it is only harder to staff.Mix languages where it helps. Each function is its own extension inside the app. A discount function in TypeScript and a Cart Transform in Rust can live side by side in one app with no penalty.
One commercial point sits alongside the technical ones. Shopify's documentation states that custom apps containing Function APIs are limited to stores on Shopify Plus. Stores on standard plans reach the same capabilities through public apps instead. If you are weighing a bespoke function against an app, our piece on custom Shopify app development and when to build or buy covers the cost side.
What this means if you are the store owner, not the developer
You do not need to pick the language. You do need to ask three questions of whoever is building it. Have they tested against your largest realistic cart? Have they pinned the CLI version so a routine update cannot break the deploy? Are the function run logs being checked, so a silent failure gets caught before your customers find it?
If you came to Functions because your Scripts stopped running, our guide on what to do now Shopify Scripts are dead covers the migration itself. And if the goal behind the custom discount is more revenue rather than parity with the old setup, it is worth stepping back. Most Shopify brands we work with from Glasgow do not have a traffic problem. They have a conversion problem, and a cleverer discount rarely fixes that on its own.
The short version
JavaScript is a first-class language for Shopify Functions and will stay one. Rust is faster, and for most discount, shipping and payment customisations the difference never reaches the limit that matters. Choose JavaScript by default, measure against your worst cart, and switch to Rust only when the instruction count or the module size forces the decision.
If you want a senior team to scope the function, build it and then measure what it does to checkout conversion, that is what our Conversion Growth Retainer is for. Get in touch and tell us what the logic needs to do.
Related articles
view all(01) Shopify Charging Shipping Twice on Multi-Location Orders? The Shipping Profile Fix
Shopify charging shipping twice on one order from two locations? Here is why shipping profiles split-rate, and the location group fix that stops it.
read article(02) Shopify Analytics vs GA4: Why the Numbers Differ and Which to Trust
Shopify Analytics vs GA4 never agree. Here is why sessions, orders and revenue differ, which one to trust for what, and how to reconcile a gap that looks wrong.
read article(03) Hiring a Shopify Agency in Manchester: What to Look For
Looking for a Shopify agency in Manchester? Here's what actually matters, what to ask before you sign, and the red flags to avoid.
read articleStay ahead of the Shopify curve
Uncover Insights brings the latest Shopify trends, practical tips, and a look behind the scenes straight to your inbox.
We won't send you spam. Unsubscribe at any time.