Blazor Warm Start

Aaron 10 Reputation points
2025-03-22T02:16:58.5333333+00:00

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.

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,766 Reputation points Volunteer Moderator
    2025-03-22T16:02:42.08+00:00

    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:

    https://github.com/dotnet/aspnetcore/issues/58875


  2. Aaron 10 Reputation points
    2025-03-23T09:54:59.6666667+00:00

    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>`
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.