What is WebAssembly?
Well, first of all, don’t think about it as an either/or decision. It’s not. WebAssembly was designed to work alongside JS, not replace it. You can have some scripts run in JS, while others are executed via WASM. Additionally, it’s not a fringe technology. As of this writing, Chrome, Firefox, Safari, Android, and even Microsoft Edge (!) support WebAssembly.
That’s part of the reason looking into WebAssembly for WordPress and other web apps is so appealing. It has already become a coding standard that’s been adopted by every major player. Including Microsoft. And we all know how hesitant they can be about this kind of thing. So if there ever was a reason to start considering how you can use it, that’s it.
To begin with, you’re going to need some sort of code in C, C++, R, etc. Then, you need to go download the Emscripten SDK, which lets you take that code and compile it to WASM.
Many of you are web developers, however, and may not have that level of polyglotitude. That’s okay. You can also write directly into the WebAssembly text style, or you can actually work your TypeScript into WASM.
With that done, Mozilla’s documentation puts it best:
Then you just run it like any other web app within your environment or CMS. Additionally, there’s an ongoing discussion among contributors about being able to import WASM scripts as modules directly, just like you can with ECMAScript (ES6) already. You’ll just indicate the script type=’module’ and that the src will be example.wasm instead of example.js.
So is WebAssembly For You?
Honestly, for the typical WordPress user, the blogger and content creator and small business owner, WebAssembly probably won’t ever concern you. And while yes, it can totally speed up your site because of how it handles calculations, it probably isn’t worth grabbing a dev and having them rework things just for that. Most WP sites aren’t heavy-duty enough to require the compression and calculations that make WebAssembly shine.
But if you’re a developer who is using the web as a home for your web app (and by this, we mean progressive web apps, not just storefronts and content delivery services unless you are super popular), WebAssembly will probably make your website run exponentially faster. If you have lots of interactions and graphics rendering, check out WASM. It will make it better. If you provide real-time analytics and data management (like CRM software), WebAssembly was designed for you.
Do you have experience with WebAssembly? What kinds of projects do you find best for the format?
Article featured image by Sammby /shutterstock.com