VOOZH about

URL: https://thenewstack.io/wasm-vs-javascript-who-wins-at-a-million-rows/

⇱ Wasm vs. JavaScript: Who wins at a million rows? - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2026-02-22 06:00:13
Wasm vs. JavaScript: Who wins at a million rows?
JavaScript / Rust / WebAssembly

Wasm vs. JavaScript: Who wins at a million rows?

By processing millions of CSV rows directly in the browser, this tutorial shows how WebAssembly outpaces JavaScript when the data gets big.
Feb 22nd, 2026 6:00am by Jessica Wachtel
👁 Featued image for: Wasm vs. JavaScript: Who wins at a million rows?
Photo by Andreas Schmidt on Unsplash.

By now it’s pretty clear that JavaScript needs WebAssembly (Wasm) to perform heavy computational tasks. In the past few weeks we’ve covered the basics, did a side-by-side image processing comparison, and saw the benefits of using Wasm with web workers.

In this next tutorial, let’s apply the same principle to real-world data using large CSV files. Instead of images or web worker computations, we’ll fetch and count millions of rows directly in the browser to compare JavaScript versus Wasm performance side by side. This will show how Wasm can make even seemingly simple tasks like counting rows lightning fast.

We’ve been switching between Rust and C (Rust for the image processing comparison and C for web workers). Though they both compile to a highly efficient Wasm with little to no performance differences for this project, we’re going to use Rust today. Rust offers safer, faster development and better JavaScript interoperability.

Before getting started, please make sure you have the following:

Node.js and npm: download here

Python 3 (we’ll be generating our large CSV using Python): download here

Rust and cargo

Local server

Let’s build our CSV processing app with Wasm,  Rust, JavaScript, and Python

First, we’re going to build our project structure. Other files and folders will be built automatically through the terminal, but here’s our starting point. Please build this structure in your code editor:

Initialize Rust

Next, we’re going to open a new terminal in your project. Open thecsv_processor/folder with the commandcd csv_processor/. Once in the file, you can initialize Rust with the command `cargo init –lib`.

This will createCargo.toml and src/lib.rs. Cargo.tomlis the Rust equivalent to thepackage.json. lib.rs is similar to a main JavaScript module file. Think of it like the Rust equivalent toindex.js.

Add Rust/ Wasm code

csv_processor/src/lib.rs

Our Rust application logic lives in this file. This code will power Wasm’s browser functionality. The top line of the file includeswasm_bindgren. wasm_bindgrenis a Rust library that makes it easy to call Rust functions from JavaScript and vice versa when compiling to WebAssembly. It handles type conversion and glue code so your Wasm module can interact seamlessly with the browser or JS code.

csv_processor/Cargo.toml

Cargo.tomldefines the project name, version, and dependencies, and tells Rust to build the library as a WebAssembly-compatible (cdylib) crate that useswasm_bindgenfor JavaScript interoperability.

Build Wasm package

Once those files are built, we’re ready to build the Wasm package. Your terminal should already be pointed to the csv_processorfolder. If not please cd csv_processor. Once there, the following command will compile your Rust code to Wasm binary.

Upon successful execution, you will see apkg/folder containing the Wasm files your browser needs to run your Rust logic.

Adding JavaScript code

index.jsis the main JavaScript file. It fetches the CSV file, initializes the WebAssembly module, counts the rows using both the Rust/Wasm function (count_rows) and pure JavaScript. It also measures how long each takes, and displays the fetch time, JS processing time, and Wasm processing time on the page when the user clicks the “Run Performance Test” button.

Build the HTML code

index.html is our main HTML page. It provides the structure and styling and includes a button to run the performance test. The page also has a paragraph to display the results. It loads index.js, which initializes the Wasm module, fetches the CSV, and compares row-counting performance.

Generate CSV using Python

generate_csv.pyincludes the simple script for building the CSV file. I chose this rather than a file download so you could change the number of rows (NUM_ROWS) to see performance differences between Wasm and JavaScript based on file size. For a file size of about 500,000 (500_000) JavaScript performs slightly faster which is similar to what we found in the web workers tutorial (smaller size = faster JavaScript). Once we get into file sizes over 2,000,000 (2_000_000), Wasm will be and stay faster.

Before building the CSV, make sure your terminal is pointed to the main project file. If you’re still incsv_processor/(which is the last place we performed terminal actions in) you can get back to the main folder with the commandcd ...

Build the CSV with the code python3 generate_csv.py. Upon successful execution, you will see a file called big.csvappear in your main project file.

Run the server and see Wasm vs JavaScript results!

Run the server with the commandserve .. You should see a response that says “Serving” with a local host address (localhost:3000). Navigate to localhost:3000in your browser and you should see the page we created. It will look like this:

👁 Image

Click the “Run Performance Test” button and you’ll see the speed comparison shortly. For the image below, I built my CSV with 2,000,000 rows and these are the results I had.

👁 Image

What results did you get? Do you see where Wasm gets faster than JavaScript?

TRENDING STORIES
Jessica Wachtel is a developer marketing writer at InfluxData where she creates content that helps make the world of time series data more understandable and accessible. Jessica has a background in software development and technical journalism.
Read more from Jessica Wachtel
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.