Member-only story

How Fast is WebAssembly Versus JavaScript?

Conducting some simple benchmarks produced some surprising results

Ashley Peacock
Better Programming

--

Photo by Veri Ivanova on Unsplash

A few days ago, I wanted to have a go at building a website that was entirely powered on the frontend by WebAssembly. The easiest way of doing that today, in my opinion, is using Microsoft’s Blazor. In essence, you can write C# code where you’d previously use JavaScript, and Blazor will compile that C# to WebAssembly to allow it to run in the browser.

However, I was a little surprised to find that when I tested the speed of it versus the application written in JavaScript, it was noticeably slower. Therefore, I decided to benchmark WebAssembly to see how it performs versus JavaScript in a real-world scenario, such as a WebAssembly module being called from JavaScript.

What Is WebAssembly?

Before we dive into the benchmarking, some of you may not be familiar with WebAssembly, so I’m going to quickly cover what it is. If you’re already familiar, feel free to skip to the next section.

WebAssembly is a low-level assembly language that can run in any major browser. It’s designed to be fast, much faster than JavaScript, in order to handle the modern use cases of the web that require higher performance. Unlike JavaScript, that uses a just-in-time compiler…

--

--

Responses (14)

What are your thoughts?