简体   繁体   English

如何减小 dotnet.wasm 大小

[英]How can i decrease dotnet.wasm size

I Have published blazor web assembly project in .net core 6 preview 7我已经在 .net core 6 preview 7 中发布了 blazor web assembly 项目

now my dotnet.wasm file size is very large and this has 64mb and its take a few minutes to download and run application In this image you can see the dotnet.wasm file size现在我的 dotnet.wasm 文件大小非常大,有 64mb,下载和运行应用程序需要几分钟时间在这张图片中,您可以看到 dotnet.wasm 文件大小

  • How can i decrease its size!?我怎样才能减小它的大小!?

i have published AOT Compilation and disabled globalization and other useless peace我已经发布了AOT编译和禁用全球化等无用的和平

You can use the Lazy Load Assembly feature available on .net 6 (and 5).您可以使用 .net 6(和 5)上提供的延迟加载程序集功能。

Look at Microsoft official documentation: https://docs.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies?view=aspnetcore-5.0看微软官方文档: https : //docs.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies?view=aspnetcore-5.0

You can decrease a lot your startup size and load time.您可以大大减少启动大小和加载时间。

You can follow the guide at https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly to enable Brotli compression.您可以按照https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly上的指南启用 Brotli 压缩。 Afterwards, you can optionally delete the uncompressed as well as the *.gz compressed files.之后,您可以选择删除未压缩的以及*.gz压缩文件。 That way, you can reduce the overall size a lot, down to a few megabytes.这样,您可以大大减少整体大小,减少到几兆字节。

Add <PublishTrimmed>true</PublishTrimmed> to your .csproj (inside PropertyGroup ).<PublishTrimmed>true</PublishTrimmed>到您的 .csproj(在PropertyGroup 内)。 Trimming will do most of the size reduction for you.修剪将为您减少大部分尺寸。 https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM