In our Blazor Web App (InteractiveAuto), the WebAssembly client takes about 7 seconds after each F5 before the application can be used, even with the browser cache already filled. Almost all of this time is spent in the browser, not waiting for the server. We measured the startup and split it into the steps below.
| Step | Time | |---|---| | Module localization texts (20 to 29 languages per module) | ~2.0 s | | Module registration and Autofac container | ~1.3 s | | Static asset list sent to the client (resource-collection.js) | ~1.2 s | | API descriptions of the static proxies (generate-proxy.json) | ~0.9 s | | Layout, menu, toolbar and first page | ~0.9 s | | Application configuration and localization requests | ~0.7 s | | Total | ~7.1 s |
Taking as an example the step with the largest weight in the table above, the module localization texts (~2.0 s): when a module's texts are used for the first time, the WebAssembly client loads the files of every language that module ships, which is between 20 and 29 languages per ABP module. Because each F5 restarts the client, this repeats on every F5.
Our application has only two languages configured, pt-PT and en. As we understand it, the only other languages ABP needs are the fallback cultures used to resolve a text: the parent culture (pt) and the default culture of each resource. Since switching language reloads the page, the remaining languages appear to be loaded but never used.
- Why does the client need to load all languages of each module, instead of only the languages configured in the application?
- If there is no specific need, could the client load only the configured languages and their fallback cultures? Or is there already a supported way to do this?
Thank you.
10 Answer(s)
-
0
In ABP Blazor WASM/WebApp, the client-side localization is resource-based and module-based, and each module typically embeds a set of JSON files for many cultures under its virtual file system (VFS). When the WASM client decides it needs a given localization resource, it pulls the resource’s JSON files exposed by the host. That’s why you see “module localization texts” as a big chunk of startup time, and why it repeats on each F5 (because the WASM runtime/app is restarted and re-initializes its localization store).
ABP’s localization fallback rules are indeed culture-based (requested culture → base culture → default culture, etc.). Those fallback rules are documented, but they do not imply the framework will only download those cultures; it only implies how a key is resolved once the relevant dictionaries are present.
So, your understanding of fallback is correct, but the current loading strategy is not “download only what’s required for fallback”.As of the verified ABP docs available here, there is no documented/supported option that tells the Blazor WASM client to “only download the cultures configured in the application + fallbacks” for module-provided virtual JSON localization files. (So there’s no officially documented switch I can point you to that changes this behavior in 10.7.)
Practical mitigations you can apply without changing ABP internals:
- Reduce the number/size of shipped localization JSONs in your own application/modules (obvious, but it’s the only fully supported lever).
- Prefer server-provided localization where possible (in a WebApp, SSR happens first; WASM then fetches configuration/culture afterwards). This doesn’t eliminate the need for client localization entirely, but it can reduce what must be ready before first interaction, depending on your UI structure.
- Measure whether you are loading localization resources earlier than necessary (e.g., during module init rather than on-demand at first use). If you can defer certain modules/components, you may defer their localization cost as well.
For the other startup costs you listed (resource-collection.js, generate-proxy.json, etc.), those are separate pipelines (static asset discovery and dynamic proxy metadata). The “load everything each F5” characteristic is normal for an Interactive WASM app because the browser refresh restarts the app; caching helps network, but not parsing/processing/DI initialization time.
Sources (validated)
- https://abp.io/docs/10.7/framework/fundamentals/localization
- https://abp.io/docs/10.7/framework/fundamentals/url-based-localization
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
By default, the WebAssembly client only gets the dynamic texts (for example, texts changed in Language Management) from the server. Static texts are read from the JSON files embedded in the module DLLs, and the JSON contributor reads every culture file of a resource the first time it needs these texts. There is no built-in option to limit this to the configured languages.
Here's a workaround you can use for now. Replace that contributor in your
Blazor.Clientproject, so it skips the culture files you don't need:using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text.RegularExpressions; using Microsoft.Extensions.FileProviders; using Volo.Abp.Localization; using Volo.Abp.Localization.VirtualFiles; using Volo.Abp.Localization.VirtualFiles.Json; namespace MyProject.Blazor.Client.Localization; public class CultureFilteredJsonLocalizationResourceContributor : JsonVirtualFileLocalizationResourceContributor { private static readonly FieldInfo VirtualPathField = typeof(VirtualFileLocalizationResourceContributorBase) .GetField("_virtualPath", BindingFlags.Instance | BindingFlags.NonPublic)!; private static readonly Regex CultureFileNameRegex = new("^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$"); private readonly HashSet<string> _cultures; public CultureFilteredJsonLocalizationResourceContributor(string virtualPath, HashSet<string> cultures) : base(virtualPath) { _cultures = cultures; } protected override bool CanParseFile(IFileInfo file) { if (!base.CanParseFile(file)) { return false; } var fileName = Path.GetFileNameWithoutExtension(file.Name); return !CultureFileNameRegex.IsMatch(fileName) || _cultures.Contains(fileName); } public static void ReplaceAll(AbpLocalizationOptions options, params string[] cultureNames) { foreach (var resource in options.Resources.Values) { var cultures = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (var cultureName in cultureNames) { cultures.Add(cultureName); cultures.Add(CultureHelper.GetBaseCultureName(cultureName)); } if (!resource.DefaultCultureName.IsNullOrEmpty()) { cultures.Add(resource.DefaultCultureName!); } for (var i = 0; i < resource.Contributors.Count; i++) { if (resource.Contributors[i].GetType() != typeof(JsonVirtualFileLocalizationResourceContributor)) { continue; } var virtualPath = (string)VirtualPathField.GetValue(resource.Contributors[i])!; resource.Contributors[i] = new CultureFilteredJsonLocalizationResourceContributor(virtualPath, cultures); } } } }Then use it in your client module:
using MyProject.Blazor.Client.Localization; using Volo.Abp.Localization; // In ConfigureServices PostConfigure<AbpLocalizationOptions>(options => { CultureFilteredJsonLocalizationResourceContributor.ReplaceAll(options, "en", "pt-PT"); });It also keeps the parent culture (
pt) and the default culture of each resource. If you add a new language later, add it to this list too.It decides by file name, not by the
cultureinside the file. A file named like a culture (tr.json,de-DE.json, or any 2-3 letter name likeapp.json) is skipped when that name isn't in the list. Other names, likeen_Books.json, are always read. The ABP module files all follow this, but please check your own localization files.The code reads the private
_virtualPathfield, so please check it again when you upgrade ABP.For the other steps in your table, could you share an online URL where we can check the startup, with a test account? Please also let us know if the times were measured with a Release build. You can send them to liming.ma@volosoft.com.
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
This question has been automatically marked as stale because it has not had recent activity.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Sorry for the delayed reply.
The access details for the test environment (URL and test user credentials) have been sent by email.
Please let us know if you run into any issues accessing it.
Thank you
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Thanks for the access.
Your client is published in Release mode with trimming enabled, so the build is fine.
On each F5, the client downloads
/api/abp/api-definition, about 690 KB of uncompressed JSON. The request comes from theDashboardsHTTP client, so your Dashboards module still uses dynamic C# client proxies. Your/api/dashboards/menuand/api/app/user-workspace/availablecalls only start after this download finishes.Switching the Dashboards module to static client proxies removes this request:
- Run your HttpApi.Host, then run this in the folder of the Dashboards
HttpApi.Clientproject:
abp generate-proxy -t csharp -u https://localhost:<your-api-host-port>/ -m dashboards --without-contracts- In the Dashboards
HttpApi.Clientmodule, replaceAddHttpClientProxieswithAddStaticHttpClientProxiesand keep the same assembly and remote service name:
context.Services.AddStaticHttpClientProxies( typeof(DashboardsApplicationContractsModule).Assembly, DashboardsRemoteServiceConsts.RemoteServiceName );The generated
*generate-proxy.jsonfile must be an embedded resource. The module template already does this. See https://abp.io/docs/latest/framework/api-development/static-csharp-clients for details.Also, the browser sends four requests to
/api/dashboards/menuon each refresh. Please check why it is called four times.If you run into any problem, you can create a private GitHub repository with a project that shows it and invite me (https://github.com/maliming). I will check it there.
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - Run your HttpApi.Host, then run this in the folder of the Dashboards
-
0
Hi,
Thanks for checking.
The Dashboards module is still in development, so we removed it from the public URL for now, so that it doesn’t get in the way of these tests.
I would like to come back to two steps from my first table. They don’t depend on Dashboards, and you can test both on the public URL.
generate-proxy.json files
On every F5, the WebAssembly client reads and deserializes all the *generate-proxy.json files of our application (the API descriptions used by the static proxies), even though the first proxy call needs only one of them. This happens in the constructor of ClientProxyApiDescriptionFinder, takes about 0.8 s in a Release build, and the first request waits for it.
On a server this cost is paid only once, but in WebAssembly it is paid again on every F5. Is there a reason to read all the files up front, instead of lazy-loading them, reading each one only when a proxy of that module is first used?
resource-collection.js
On every F5, before the first page renders, the WebAssembly client loads resource-collection.js and builds a lookup of all static files of the application (over 15,000 entries). On the public URL this takes about 0.5 s, and the first page waits for it.
As far as we can tell, only @Assets, ImportMap and ResourcePreloader use this lookup. Our client uses none of them, and neither do the ABP and LeptonX packages.
Is there a supported way to skip this lookup in the WebAssembly client, or to make it smaller?
Together with the localization workaround you already gave us, solving these two points would remove a good part of the startup time on every F5, and bring it to an acceptable level for our users.
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
There is no special reason to read all
*generate-proxy.jsonfiles up front.ClientProxyApiDescriptionFinderreads all of them when it's first created. We'll change it in ABP to read each file only when it's needed.For now, you can add this class to your
Blazor.Clientproject. It replaces the default one and reads a file only when one of its services is first called:using System; using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Extensions.FileProviders; using Volo.Abp.DependencyInjection; using Volo.Abp.Http.Client.ClientProxying; using Volo.Abp.Http.Modeling; using Volo.Abp.Json; using Volo.Abp.VirtualFileSystem; namespace MyCompanyName.MyProjectName.Blazor.Client; [Dependency(ReplaceServices = true)] [ExposeServices(typeof(IClientProxyApiDescriptionFinder))] public class LazyClientProxyApiDescriptionFinder : ClientProxyApiDescriptionFinder { private readonly object _syncLock = new(); private readonly List<IFileInfo> _pendingFiles = new(); private readonly Dictionary<IFileInfo, List<string>> _fileServiceTypes = new(); public LazyClientProxyApiDescriptionFinder( IVirtualFileProvider virtualFileProvider, IJsonSerializer jsonSerializer) : base(virtualFileProvider, jsonSerializer) { } public override ActionApiDescriptionModel? FindAction(string methodName) { lock (_syncLock) { var action = base.FindAction(methodName); if (action == null && _pendingFiles.Count > 0) { LoadFiles(_pendingFiles.Where(file => HasServiceOf(file, methodName)).ToList()); action = base.FindAction(methodName); } if (action == null && _pendingFiles.Count > 0) { LoadFiles(_pendingFiles.ToList()); action = base.FindAction(methodName); } return action; } } public override ApplicationApiDescriptionModel GetApiDescription() { lock (_syncLock) { LoadFiles(_pendingFiles.ToList()); return base.GetApiDescription(); } } protected override void Initialize() { // Only find the files here, and read each file when one of its services is first called. ApplicationApiDescriptionModel = ApplicationApiDescriptionModel.Create(); GetGenerateProxyFileInfos(_pendingFiles); } private void LoadFiles(List<IFileInfo> files) { foreach (var file in files) { var model = JsonSerializer.Deserialize<ApplicationApiDescriptionModel>(ReadFile(file)); foreach (var module in model.Modules.Values) { if (ApplicationApiDescriptionModel.Modules.ContainsKey(module.RootPath)) { continue; } ApplicationApiDescriptionModel.AddModule(module); foreach (var controller in module.Controllers.Values.Where(x => x.Interfaces.Any())) { var appServiceType = controller.Interfaces.Last().Type; foreach (var actionItem in controller.Actions.Values) { var actionKey = $"{appServiceType}.{actionItem.Name}.{string.Join("-", actionItem.ParametersOnMethod.Select(x => x.Type))}"; ActionApiDescriptionModels.TryAdd(actionKey, actionItem); } } } _pendingFiles.Remove(file); _fileServiceTypes.Remove(file); } } private bool HasServiceOf(IFileInfo file, string methodName) { if (!_fileServiceTypes.TryGetValue(file, out var types)) { types = FindServiceTypes(ReadFile(file)); _fileServiceTypes[file] = types; } return types.Any(type => methodName.StartsWith(type + ".", StringComparison.Ordinal)); } private static string ReadFile(IFileInfo file) { using var streamReader = new StreamReader(file.CreateReadStream()); return streamReader.ReadToEnd(); } private static List<string> FindServiceTypes(string json) { // Collects the "type" values between each "interfaces" and the following "actions". // The service types are among them, and the action keys start with the service type. var types = new List<string>(); var index = json.IndexOf("\"interfaces\"", StringComparison.Ordinal); while (index >= 0) { var end = json.IndexOf("\"actions\"", index, StringComparison.Ordinal); if (end < 0) { end = json.Length; } var typeIndex = json.IndexOf("\"type\"", index, end - index, StringComparison.Ordinal); while (typeIndex >= 0) { var colon = json.IndexOf(':', typeIndex + 6); var valueStart = colon < 0 ? -1 : json.IndexOf('"', colon + 1); var valueEnd = valueStart < 0 ? -1 : json.IndexOf('"', valueStart + 1); if (valueEnd < 0 || valueEnd > end) { break; } types.Add(json.Substring(valueStart + 1, valueEnd - valueStart - 1)); typeIndex = json.IndexOf("\"type\"", valueEnd, end - valueEnd, StringComparison.Ordinal); } index = json.IndexOf("\"interfaces\"", end, StringComparison.Ordinal); } return types; } }ASP.NET Core has no option to skip
resource-collection.js, but you can make it smaller. In a new 10.7 Blazor Web App, about 65% of its entries are the single bootstrap-icons SVG files from LeptonX and the locale files underlibs. You can remove them from the static assets manifest and serve them withUseStaticFiles, as described in the ASP.NET Core docs: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-10.0#large-collection-of-assets- Add this to the csproj of your Blazor project (the server project, not
Blazor.Client):
<PropertyGroup> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);_content/Volo.Abp.AspNetCore.Components.Web.LeptonXTheme/side-menu/libs/bootstrap-icons/icons/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);_content/Volo.Abp.AspNetCore.Components.Web.LeptonXTheme/side-menu/libs/bootstrap-datepicker/locales/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);libs/moment/locale/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);libs/jquery-validation/localization/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);libs/bootstrap-datepicker/locales/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);libs/timeago/locales/**</StaticWebAssetEndpointExclusionPattern> <StaticWebAssetEndpointExclusionPattern>$(StaticWebAssetEndpointExclusionPattern);libs/select2/js/i18n/**</StaticWebAssetEndpointExclusionPattern> </PropertyGroup>- In your Blazor module, add
app.UseStaticFiles()right afterapp.UseRouting(), and keepapp.MapAbpStaticAssets()as it is:
app.UseRouting(); app.UseStaticFiles();In a Release build, this reduces
resource-collection.jsfrom 3.2 MB to 1 MB. The excluded files are still available, but they're no longer served compressed. You can check the*.staticwebassets.endpoints.jsonfile in your publish folder to find other folders to exclude.Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) - Add this to the csproj of your Blazor project (the server project, not
-
0
Hi,
ABP 11.0 stable will include the
generate-proxy.jsonoptimization: https://github.com/abpframework/abp/pull/26488. After upgrading, you can remove theLazyClientProxyApiDescriptionFinderclass.The localization change is also in 11.0 (https://github.com/abpframework/abp/pull/26378), so you can remove the
CultureFilteredJsonLocalizationResourceContributorworkaround too.Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
Hi,
Thank you for the detailed answers, and for including both changes in ABP 11.0. We will use the workarounds until we upgrade, and remove them afterwards. We will also try your suggestion to make resource-collection.js smaller.
Since two of the points we reported led to changes in ABP itself, could you let us know if this question qualifies for a credit refund?
Thanks
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)