diff --git a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.Server.ts b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.Server.ts index 5ca90c0df6..b0a917b464 100644 --- a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.Server.ts +++ b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.Server.ts @@ -6,10 +6,16 @@ import { MessagePackHubProtocol } from '@aspnet/signalr-protocol-msgpack'; import { OutOfProcessRenderBatch } from './Rendering/RenderBatch/OutOfProcessRenderBatch'; import { internalFunctions as uriHelperFunctions } from './Services/UriHelper'; import { renderBatch } from './Rendering/Renderer'; +import { fetchBootConfigAsync, loadEmbeddedResourcesAsync } from './BootCommon'; let connection : signalR.HubConnection; function boot() { + // In the background, start loading the boot config and any embedded resources + const embeddedResourcesPromise = fetchBootConfigAsync().then(bootConfig => { + return loadEmbeddedResourcesAsync(bootConfig); + }); + connection = new signalR.HubConnectionBuilder() .withUrl('/_blazor') .withHubProtocol(new MessagePackHubProtocol()) @@ -24,13 +30,16 @@ function boot() { connection.on('JS.Error', unhandledError); connection.start() - .then(() => { + .then(async () => { DotNet.attachDispatcher({ beginInvokeDotNetFromJS: (callId, assemblyName, methodIdentifier, argsJson) => { connection.send('BeginInvokeDotNetFromJS', callId ? callId.toString() : null, assemblyName, methodIdentifier, argsJson); } }); + // Ensure any embedded resources have been loaded before starting the app + await embeddedResourcesPromise; + connection.send( 'StartCircuit', uriHelperFunctions.getLocationHref(), diff --git a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.WebAssembly.ts b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.WebAssembly.ts index 249b716267..f2863a3581 100644 --- a/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.WebAssembly.ts +++ b/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Boot.WebAssembly.ts @@ -7,6 +7,7 @@ import { renderBatch } from './Rendering/Renderer'; import { RenderBatch } from './Rendering/RenderBatch/RenderBatch'; import { SharedMemoryRenderBatch } from './Rendering/RenderBatch/SharedMemoryRenderBatch'; import { Pointer } from './Platform/Platform'; +import { fetchBootConfigAsync, loadEmbeddedResourcesAsync } from './BootCommon'; async function boot() { // Configure environment for execution under Mono WebAssembly with shared-memory rendering @@ -16,11 +17,8 @@ async function boot() { }; // Fetch the boot JSON file - // Later we might make the location of this configurable (e.g., as an attribute on the