Why use JavaScript?
With Blazor WebAssembly, we can create robust applications without writing any JavaScript. However, there are some scenarios that require the use of JavaScript. For example, we may have a favorite JavaScript library that we want to continue to use. Also, without JavaScript, we can't manipulate the DOM or call any of the JavaScript APIs.
This is a partial list of things that we do not have access to directly from the Blazor WebAssembly framework:
- DOM manipulation
- The Media Capture and Streams API
- The WebGL API (2D and 3D graphics for the web)
- The Web Storage API (
localStorage
andsessionStorage
) - The Geolocation API
- JavaScript popup boxes (alert box, confirm box, prompt box)
- The online status of the browser
- The browser's history
- Chart.js
- Other third-party JavaScript libraries
The preceding list is not at all comprehensive since there are hundreds of JavaScript libraries that are currently available. However, the key point to remember is that we cannot manipulate...