Chapter 10: JavaScript Interop
In this chapter, we will take a look at JavaScript. In certain scenarios, we still need to use JavaScript or we want to use an existing library that relies on JavaScript. Blazor uses JavaScript to update the Document Object Model (DOM), download files, and access things such as local storage on the client.
So, there are, and always will be, cases when we need to communicate with JavaScript, or have JavaScript communicate with us. Don’t worry. The Blazor community is an amazing one, so chances are someone has already built the interop that we need.
In this chapter, we will cover the following topics:
- Why do we need JavaScript?
- .NET to JavaScript
- JavaScript to .NET
- Implementing an existing JavaScript library