Close

Sign up to Gadget

Understanding Shopify Functions. Part 1: What they are, and why they’re important

-

About

Learn what Shopify Functions are, why they’re the future of building customizations on Shopify and how you can make the most of them.

Problem

Solution

Result

Understanding Shopify Functions. Part 1: What they are, and why they’re important

Ralf Elfving
February 17, 2023

Shopify Functions was announced during Summer Editions 2022 as a new, fundamental way to extend and customize Shopify. But most merchants and developers in the ecosystem don’t know what Functions are, why they’re important, or what they can be used for.

In this two-part blog post, we’ll explain what Functions are and why they’re important, and arm you with the knowledge so you can be an early adopter of this new, powerful Shopify feature.


We’ve broken this down into two parts. In this first part, we’ll cover what Shopify Functions are, why Shopify introduced them, and why they’re likely a cornerstone to the future of building Shopify customization. In the second part, we’ll explore what you can build with Functions, and how you can get started building your first Function!

What are Functions?

Commerce is ever-evolving, and Shopify needs to evolve with it in order to provide ever-improving buyer experiences. Shopify introduced Functions to open up ways for the thousands of developers in the Shopify ecosystem to help extend and customize the platform.

Functions are small pieces of code that power very specific customization use cases. Early examples include the ability to provide more powerful and flexible discount logic during the checkout flow, customize what payment and delivery options that are available, and how they’re presented. Shopify’s Winter Editions 2023 saw the expansion of Functions use cases, including the creation of product bundles or the validation of cart contents.

Graphics displaying how Functions unlock backend functionality, from Shopify’s announcement post.

And importantly these small pieces of code run on Shopify’s servers with very strict performance requirements, enabling customization without the risk of degrading performance and a poor buyer experience.

Gee, that sounds a lot like Shopify Scripts

For those who have been around the Shopify ecosystem for a while might say that this sounds a lot like Shopify Scripts, which was introduced by Shopify in 2016. And it’s true, Functions and Scripts are very similar. But there are some key differences.

Scripts are only available to merchants on the Shopify Plus plan, while public apps using Functions are available on all plans. The functionality that once was gated to only Plus merchants will now be unlocked for everyone.

Another difference is that Scripts require developers to have some familiarity with Ruby to run their scripts, while Functions allow developers to choose from a wider range of languages. Developers can use any language that compiles down to WebAssembly (WASM), such as AssemblyScript or Rust, so long as the compiled .wasm file is under Shopify’s specified size limit (256 kB at the time this post was written). Shopify is also working on a JavaScript implementation for Functions that is available for local testing but cannot yet be deployed to Shopify.

Foremost, Shopify has set a performance limit that requires Functions to execute in a mind-whopping 5ms, which makes it 100x faster than Scripts. In an age where milliseconds impact conversion metrics and merchants run massive flash sales, that performance really adds up.

This super-fast execution is why Shopify feels confident to open up more parts of their buyer-facing experiences to customization; areas of the platform that used to be off-limits to developers outside of Shopify themselves.

A win-win-win-win

With Functions Shopify is able to have their cake, eat it too, and share it with the rest of the world. Thousands of developers in the Shopify ecosystem can build new and unique customizations, covering use cases that Shopify could never have imagined, let alone had time to build. These will help merchants provide experiences that are tailored to their business, providing buyers with unique and delightful experiences. All the while Shopify ensures that the platform stays performant, with no negative buyer experiences. It’s a win-win-win-win scenario for Shopify, developers, merchants, and buyers!

This means that Functions is likely the way in which Shopify will continue to unlock more customization options in new areas of the buyer experience, such as checkout.

What’s next?

Since announcing Functions in the summer of 2022, Shopify has extended the number of available Functions APIs to four. Another four are in developer preview, and many more are likely to follow in the future.

In the second part of this article, we go more into detail about what these different options are, and give you hands-on tips on how to get started building with them. If you’re a developer in the ecosystem, Functions will likely become a core competency that is definitely worth learning.

Interested in learning more about Gadget?

Join leading agencies making the switch to Gadget and experience the difference a fullstack platform can make.
Keep reading to learn about how it's built

Under the hood

We're on Discord, drop in and say hi!
Join Discord
Bouncing Arrow