What is WebAssembly?
WebAssembly is a binary instruction format that allows code written in high-level languages, such as C#, to run on the browser at near-native speed. To run .NET binaries in a web browser, it uses a version of the .NET runtime that has been compiled to WebAssembly. You can think of it as executing natively compiled code in a browser.
WebAssembly is an open standard developed by a W3C Community Group. It was originally announced in 2015, and the first browser that supported it was released in 2017.
WebAssembly goals
When WebAssembly was originally being developed, there were four main design goals for the project. This is a list of the original goals for WebAssembly:
- Fast and efficient
- Safe
- Open
- Don’t break the web
WebAssembly is fast and efficient. It is designed to allow developers to write code in any language that can then be compiled to run in the browser. Since the code is compiled, it is fast and performs at near-native speed.
WebAssembly is safe. It does not allow direct interaction with the browser’s DOM. Instead, it runs in its own memory-safe, sandboxed execution environment. You must use JavaScript interop to interact with the DOM. The project in Chapter 5, Building a Local Storage Service Using JavaScript Interoperability (JS interop), will teach you how to use JavaScript interop.
WebAssembly is open. Although it is a low-level assembly language, it can be edited and debugged by hand.
WebAssembly didn’t break the web. It is a web standard that is designed to work with other web technologies. Also, WebAssembly modules can access the same Web APIs that are accessible from JavaScript.
Overall, WebAssembly was able to meet all of the original goals and rapidly gained support from all of the modern browsers.
WebAssembly support
As mentioned earlier, WebAssembly runs on all modern browsers, including mobile browsers. As you can see from the following table, all current versions of the most popular browsers are compatible with WebAssembly:
Browser |
Version |
Microsoft Edge |
Current |
Mozilla Firefox, including Android |
Current |
Google Chrome, including Android |
Current |
Safari, including iOS |
Current |
Opera, including Android |
Current |
Microsoft Internet Explorer |
Not Supported |
Table 1.2: WebAssembly browser compatibility
IMPORTANT NOTE
Microsoft Internet Explorer is no longer supported by Microsoft as of June 15, 2022. It does not support WebAssembly and will never support WebAssembly.
WebAssembly is a web standard that allows developers to run code written in any language in the browser. It is supported by all modern browsers.
Now that we have discussed the benefits of using the Blazor framework and compared the various hosting models, it’s time to start developing using the Blazor WebAssembly framework. However, before we can get started, you need to set up your PC.