Chapter 7. Dynamic linking: The basics

 

This chapter covers

  • How dynamic linking works for WebAssembly modules
  • Why you might want to use dynamic linking and why you might not
  • How to create WebAssembly modules as main or side modules
  • What the different options are for dynamic linking and how to use each approach

When it comes to WebAssembly modules, dynamic linking is the process of joining two or more modules together at runtime, where the unresolved symbols from one module (functions, for example) resolve to symbols existing in another. You’ll still have the original number of WebAssembly modules, but now they’re linked together and able to access each other’s functionality, as figure 7.1 shows.

Figure 7.1. At runtime, the logic from one module (Module 2, in this case) is linked to another module (Module 1), allowing the two to communicate and act as one.

You can implement dynamic linking for WebAssembly modules in several ways, making this a large topic. You’ll learn how to build a website that uses dynamic linking in chapter 8, but first you’ll need to learn what your options are.

7.1. Dynamic linking: Pros and cons

Why would you want to use dynamic linking instead of just using the single WebAssembly module approach that you’ve used so far in this book? You might consider using dynamic linking for several reasons:

7.2. Dynamic linking options

7.3. Dynamic linking review

Real-world use cases

Exercises

Summary

sitemap