BlazorWasmBrotliLoader.Build 1.0.0

dotnet add package BlazorWasmBrotliLoader.Build --version 1.0.0                
NuGet\Install-Package BlazorWasmBrotliLoader.Build -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorWasmBrotliLoader.Build" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorWasmBrotliLoader.Build --version 1.0.0                
#r "nuget: BlazorWasmBrotliLoader.Build, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorWasmBrotliLoader.Build as a Cake Addin
#addin nuget:?package=BlazorWasmBrotliLoader.Build&version=1.0.0

// Install BlazorWasmBrotliLoader.Build as a Cake Tool
#tool nuget:?package=BlazorWasmBrotliLoader.Build&version=1.0.0                

BlazorWasmBrotliLoader.Build

NuGet Package Discord

📝Summary

When you publish your Blazor WebAssembly app, this package rewrites the fallback page file (wwwroot/index.html) to be loading Brotli pre-compressed application files, such as *.wasm.br.

Before: 5.5MB transferred, After: 2.2MB transferred

Pre-compressed files are smaller than original one, so this package will help make your Blazor WebAssembly app boot much faster than usual, sinse it reduce the initial content loading time.

🚀Quick Start

Install this package to your Blazor WebAssembly project.

dotnet add package BlazorWasmBrotliLoader.Build

Basically, that's all.

Once you install this package, the output of the dotnet publish command will make the wwwroot/index.html load *.wasm.br files! 🎉

[!IMPORTANT]
If the Blazor WebAssembly app is hosted on a server that supports Brotli compression, you don't have to use this package. For example, the ASP.NET Core server of .NET9 will handle them well (see also here). This package is only useful for an app hosted on a server that doesn't support Brotli compression, such as a simple static content server, such as GitHub Pages.

[!NOTE]
In fact, you can implement the feature of loading Brotli pre-compressed files by yourself without depending on this package. Microsoft's official document tells us how to do it. But it can be hard work, particularly if you are implementing a PWA. This NuGet package allows us to use pre-compression application files out of the box!

[!NOTE]
For years, the feature of loading Brotli pre-compressed files has been built into the "PublishSPAforGitHubPages.Build" package. However, since it is strongly tied to publishing on GitHub Pages, it can not be used on other platforms. So, I decided to split this feature into an individual package.

🛜 PWAs and Service Workers

If your Blazor WebAssembly PWA loading Brotli pre-compressed files needs to run offline, please ensure the service worker loads "*.br" files in the offline cache. For example, if you generated your Blazor WebAssmebly PWA project by the standard project template, you will need to update the wwwroot/service-worker-published.js file. In this case, you need to append the /\.br$/ regex pattern to the definition of the offlineAssetsInclude array constant variable in the wwwroot/service-worker-published.js file.

// 🗒️ wwwroot/service-worker-published.js
...
const offlineAssetsInclude = [ 
  /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/,
  /\.br$/ // 👈 Add this line
];

⚙️Configurations

If you don't want to enable the Brotli pre-compressed file loading feature, set the BrotliLoaderInjectLoader MSBuild property to false. For example, you can do it in the dotnet publish command as below.

dotnet publish -p BrotliLoaderInjectLoader=false

🎉Release notes

Release notes

📢License

Mozilla Public License Version 2.0

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on BlazorWasmBrotliLoader.Build:

Package Downloads
PublishSPAforGitHubPages.Build

This package provides post published processing to deploy the .NET Core SPA project (such as Blazor WebAssembly) as a GitHub pages site. (rewriting base URL in "index.html", generating ".nojekyll" ".gitattributes" and "404.html".)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1,361 9/23/2024

v.1.0.0
- 1st release.;

To see all the change logs, please visit the following URL.
- https://github.com/jsakamoto/BrotliLoader.Build/blob/master/RELEASE-NOTES.txt