The more supported way of doing this is to have landing page content be a blazor page and use server pre-render.
While preload does currently exist, see this issue:
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a landing page and when the user clicks a button it does Blazor.start();
Q. Is there a way that I can do something like Blazor.preload();
where it will preload the *.wasm assemblies into the Wasm runtime while the user is reading the landing page information. Then the Blazor.start();
already has a good head start and the blazor app launches more quickly for the user.
The more supported way of doing this is to have landing page content be a blazor page and use server pre-render.
While preload does currently exist, see this issue:
Just encase someone else reads this, this is what I landed on (until there is something official).
I already had a <div>
for the static (landing page) content and a <div>
for the Blazor app, so I simply moved the Blazor.start();
to happen as the index.html
is loading. It is at the end of the page so the content is rendered first. The button to start the Blazor app now just simply toggles the two div's to show the Blazor app. If its still loading then you see the loading spinner but if you wait to read more of the landing page content, then you go straight into the Blazor app when they click the button (as it has loaded into the hidden div.
so at the end of the index.html the code looks like this
<script>
function startApp() {
document.getElementById('static').hidden = true;
document.getElementById('app').hidden = false;
}
var static = document.getElementById('static');
if (static.offsetParent != null && window.location.pathname.length > 1) {
window.location.href = '/';
}
Blazor.start();
</script>`