Lazy loaded `BlazorCustomElements.js` file does not adhere to the `loadBootResource` configuration
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hi guys,
Since .NET 7 is out, I’ve been test driving Blazor WASM to see how to use it in combination with other frameworks.
I’ve configured the following to be able to point the loading of resources to a specific server. https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-7.0#load-boot-resources
Which works nicely.
I’m now using the Microsoft.AspNetCore.Components.CustomElements nuget package to get CustomElements to work.
Initially you had to reference the script manually:
<script src="_content/Microsoft.AspNetCore.Components.CustomElements/BlazorCustomElements.js"></script>
But since .NET 7 has been released it’s lazy loaded by ASP.NET. Which is awesome. The only problem is: it uses the URL of the server you are on, to lazy load the file, while it should be respecting the loadBootResource configuration.
Which is a problem for me, as I’m depending on the loadBootResource function to get the WASM files from another server, for example a CDN.
Is that something you guys can fix?
cc: @guardrex https://github.com/dotnet/AspNetCore.Docs/issues/27638
Expected Behavior
Loading the JS for CustomElements should respect the loadBootResource configuration.
Steps To Reproduce
- Create a Blazor WASM client app
- Create a simple webserver that loads the Blazor script with
autostart="false"and add the following bootstrapping lines:
Blazor.start({
loadBootResource: function (type, name, defaultUri, integrity) {
return 'https://localhost:8088/' + defaultUri`;
}
});
- Install the CustomElements nuget and implement a basic customelement.
- Try loading the basic webserver with the customelement and blazor script.
Exceptions (if any)
No response
.NET Version
7
Anything else?
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
I’ve filed an issue describing this as a general feature request: https://github.com/dotnet/aspnetcore/issues/45148
A more practical solution for you in the short term would be to implement a service worker that will let you override how all static resources are fetched.
Thanks!