Overview
Startup is asynchronous and automatic via blazor.web|server|webassembly.js
.
Manually Starting Blazor
Manually Starting Blazor Web App
- Add
autostart="false"
to the Blazor<script>
tag. - Place a script that calls
Blazor.start()
after the<script>
tag inside the closing<body>
tag. - Place static SSR options in the
ssr
property. - Place server-side Blazor SignalR circuit options in the
circuit
property. - Place client-side WebAssembly options in the
webAssembly
property.
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
<script>
...
Blazor.start({
ssr: {
...
},
circuit: {
...
},
webAssembly: {
...
}
});
...
</script>
Manually Starting Standalone Blazor Wasm and Blazor Server
- Add
autostart="false"
to the Blazor<script>
tag. - Place a script that calls
Blazor.start()
after the<script>
tag inside the closing<body>
tag. - Add any options in the
Blazor.start()
parameter.
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
<script>
...
Blazor.start({
...
});
...
</script>
JavaScript Initializers
JS initializers execute logic before and after a Blazor app loads.
Initialize Blazor when the Document is Ready
<script src="{BLAZOR SCRIPT}" autostart="false"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
Blazor.start();
});
</script>