Skip to content

Commit c0b59c0

Browse files
Merge branch 'development' into BLAZ-983104-split
2 parents fece153 + 50b62b6 commit c0b59c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1187
-915
lines changed

blazor/common/aot-compilation/optimize-performance-blazor-wasm.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
---
22
layout: post
3-
title: Optimize Performance in Blazor WASM using AOT Compilation - Syncfusion
4-
description: Check out the documentation for Optimize Performance using AOT Compilation in Blazor WebAssembly in Blazor
3+
title: Optimize Blazor WASM performance with AOT compilation - Syncfusion
4+
description: Enable AOT compilation in Blazor WebAssembly to improve performance, understand trade-offs, and review size versus performance considerations and more details.
55
platform: Blazor
6-
component: Common
6+
control: Common
77
documentation: ug
88
---
99

10-
# Optimize Performance in Blazor WebAssembly using AOT Compilation
10+
# Optimize Blazor WebAssembly performance with AOT compilation
1111

12-
This article explains how to improve the performance of **Blazor WebAssembly (WASM)** applications using **Ahead-of-Time (AOT) compilation**, specifically for applications using **Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components**.
12+
This article explains how to improve the performance of Blazor WebAssembly (WASM) Apps using **Ahead-of-Time (AOT) compilation**, including apps that use Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components.
1313

1414
## AOT Compilation Overview
1515

16-
Blazor WebAssembly applications run entirely in the browser via WebAssembly. By default, the app’s .NET assemblies are downloaded and executed using a **Just-In-Time (JIT)** interpreter. However, enabling **AOT compilation** ahead of time converts the .NET Intermediate Language (IL) into native WebAssembly at build time, resulting in significant performance gains.
16+
Blazor WebAssembly Apps run entirely in the browser via WebAssembly. By default, the app’s .NET assemblies are downloaded and executed using a **Just-In-Time (JIT)** interpreter. Enabling AOT compilation converts .NET Intermediate Language (IL) into native WebAssembly at build time, which can provide significant performance gains.
1717

1818
## Enable AOT Compilation
1919

20-
Follow the steps below to configure AOT for your Blazor WASM project.
20+
Follow these steps to configure AOT for a Blazor WebAssembly App.
21+
22+
**Prerequisites:** Target .NET 8 or later and publish in Release configuration.
2123

2224
### Step 1: Target .NET 8+
2325

@@ -62,7 +64,7 @@ bin/Release/net8.0/publish/wwwroot/
6264
---
6365

6466
## Size vs Performance Tradeoff
65-
The following table compares performance and size metrics for Blazor WebAssembly with and without AOT, using a Syncfusion<sup style="font-size:70%">&reg;</sup> Grid with paging enabled.
67+
The following sample metrics compare performance and size for Blazor WebAssembly with and without AOT, using a Syncfusion<sup style="font-size:70%">&reg;</sup> Grid with paging enabled.
6668

6769
| Metric | Without AOT | With AOT |
6870
|----------------------------|----------------------|----------------------|
@@ -71,32 +73,32 @@ The following table compares performance and size metrics for Blazor WebAssembly
7173
| Bundle Size (Brotli) | ~114 MB | ~192 MB |
7274
| Memory Usage | Slightly lower | Slightly higher |
7375

74-
> [AOT compilation](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot?view=aspnetcore-9.0#ahead-of-time-aot-compilation) increases the application size but significantly improves load time, interactivity and overall runtime performance in Blazor WebAssembly applications.
76+
> [AOT compilation](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot#ahead-of-time-aot-compilation) increases app size but can significantly improve load time, interactivity, and overall runtime performance in Blazor WebAssembly apps.
7577
7678
---
7779

7880
## Limitations
7981

80-
- **Longer Build Time:** AOT compilation is slower compared to standard builds.
81-
- **Increased Bundle Size:** Final WebAssembly size is larger.
82-
- **Higher Memory Usage:** While AOT improves performance, it may result in slightly higher memory usage at runtime due to native code execution.
83-
- **Reduced Flexibility:** Dynamic features (e.g., reflection) may require additional handling.
84-
- **More Complex Debugging:** Source map support is limited.
85-
- **Slower Iterations:** Any code change needs full rebuild, affecting dev productivity.
82+
- **Longer build time:** compared to standard builds.
83+
- **Increased bundle size:** Final WebAssembly size is larger.
84+
- **Higher memory usage:** While AOT improves performance, it may result in slightly higher memory usage at runtime due to native code execution.
85+
- **Reduced flexibility:** Dynamic features (e.g., reflection) may require additional handling.
86+
- **More complex debugging:** Source map support is limited.
87+
- **Slower iterations:** Any code change needs full rebuild, affecting dev productivity.
8688

8789
---
8890

8991
## Considerations
9092

91-
- **Better Performance:** Native WebAssembly improves execution speed and UI responsiveness.
92-
- **Enhanced Security:** Native code is harder to reverse-engineer than Intermediate Language code.
93-
- **Cross-Platform Consistency:** Consistent behavior across browsers and devices.
93+
- **Better performance:** Native WebAssembly improves execution speed and UI responsiveness.
94+
- **Enhanced security:** Native code is harder to reverse-engineer than Intermediate Language code.
95+
- **Cross-platform consistency:** Consistent behavior across browsers and devices.
9496

9597
---
9698

9799
## Specific Recommendations
98100

99-
To further reduce published output size, [enable linker and trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options#enable-trimming) options in your `.csproj`:
101+
To further reduce published output size, [enable linker and trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options#enable-trimming) options in the `.csproj`.
100102

101103
```xml
102104
<PublishTrimmed>true</PublishTrimmed>

blazor/common/aot-compilation/reduce-size-of-blazor-wasm.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
---
22
layout: post
3-
title: Reduce Size of Blazor WebAssembly Application - Syncfusion
4-
description: Check out the documentation for reduce size of blazor webassembly application in blazor using various techniques
3+
title: Reduce size of Blazor WebAssembly Applications - Syncfusion
4+
description: Learn here all about how to reduce Syncfusion Blazor WebAssembly (WASM) App size using trimming and linker configuration. Explore here to more details.
55
platform: Blazor
6-
component: Common
6+
control: Common
77
documentation: ug
88
---
99

10-
# Reduce Size of Blazor WebAssembly Application
10+
# Reduce size of Blazor WebAssembly Application
1111

12-
This article explains how to reduce the size of **Blazor WebAssembly (WASM)** applications. Although [Ahead-of-Time (AOT)](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot?view=aspnetcore-9.0#ahead-of-time-aot-compilation) compilation improves performance, it also increases the app size. To help reduce this, you can enable code trimming options in our projects. Trimming automatically removes unused code from the final output, which helps lower the bundle size without affecting functionality. This is especially helpful when using large projects.
12+
This article explains how to reduce the size of **Blazor WebAssembly (WASM)** applications. Although [Ahead-of-Time (AOT) compilation](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot#ahead-of-time-aot-compilation) improves performance, it also increases app size. To reduce size, enable code trimming options in projects. Trimming removes unused code from the final output, helping lower the bundle size without affecting functionality.
1313

1414
## Configure the Linker for ASP.NET Core Blazor
1515

16-
Blazor WebAssembly uses [Intermediate Language (IL) linking](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot?view=aspnetcore-9.0#trim-net-il-after-ahead-of-time-aot-compilation) to trim unused code from the final output during build. This process is **only enabled in Release builds** and is **disabled in Debug configuration** by default. To take full advantage of trimming and reduce the size of the published application, it is recommended to **build your app in Release mode** before deployment.
16+
Blazor WebAssembly uses [Intermediate Language (IL) linking](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-build-tools-and-aot#trim-net-il-after-ahead-of-time-aot-compilation) to trim unused code from the final output during build. This process is only enabled in Release builds and is disabled in Debug by default. To take full advantage of trimming and reduce the size of the published app, publish in Release mode before deployment.
1717

1818
> Always publish your Blazor WebAssembly app using the `Release` configuration to enable trimming and optimize performance.
1919
20-
### Disable Intermediate Language Linking (Optional)
20+
### Disable Intermediate Language linking (optional)
2121

2222
To manually disable Intermediate Language linking, add the following MSBuild property in your `.csproj` file:
2323

@@ -28,7 +28,7 @@ To manually disable Intermediate Language linking, add the following MSBuild pro
2828
```
2929
## Enable trimming
3030

31-
**PublishTrimmed** property enables code trimming for self-contained publishing.It automatically disables features that aren’t compatible with trimming and provides warnings about trimming conflicts during build.
31+
The **PublishTrimmed** property enables code trimming for self-contained publishing. It automatically disables features that are not compatible with trimming and provides warnings about trimming conflicts during build.
3232

3333
To [enable trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options#enable-trimming), add the following to your `.csproj` file:
3434

@@ -40,21 +40,21 @@ To [enable trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/tri
4040

4141
## Trim mode
4242

43-
For all assemblies in a Blazor application, trimming is enabled by default from the.NET 8 target framework. Trim warnings may cause problems for applications that have previously used `PublishTrimmed=true` and `TrimMode=partial`. However, if your application compiles without any trim warnings, this default behavior shouldn't interfere with functionality or cause issues. For more information, refer to the [trim configuration](https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-trimmer?view=aspnetcore-9.0) documentation to achieve this.
43+
For all assemblies in a Blazor application, trimming is enabled by default starting with the .NET 8 target framework. Trim warnings may occur for apps that previously used `PublishTrimmed=true` and `TrimMode=partial`. If the app compiles without trim warnings, this default behavior should not affect functionality. For more information, refer to the [trim configuration](https://learn.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/configure-trimmer) documentation.
4444

4545
### To Resolve trim warnings
4646

47-
Partial trimming is less aggressive and may be safer for applications that use reflection. To ensure smooth builds, resolve all trim warnings in our application, make the below changes in our `.csproj` to resolve the trim warnings
47+
Partial trimming is less aggressive and may be safer for applications that use reflection. To ensure smooth builds, resolve all trim warnings in the application. If needed, make the following change in the `.csproj` file:
4848

4949
```xml
5050
<TrimMode>partial</TrimMode>
5151
```
5252

5353
## Enable Link Trimming
5454

55-
To control **Intermediate Language (IL)** trimming on a per-assembly basis by supplying an XML configuration file. This approach allows you to explicitly preserve assemblies, types, or members that may be trimmed, even if they are not directly referenced in your application code.
55+
Control Intermediate Language (IL) trimming on a per-assembly basis by supplying an XML configuration file. This approach allows explicitly preserving assemblies, types, or members that may be trimmed, even if they are not directly referenced in application code.
5656

57-
To [enable Intermediate Language trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming#enable-project-specific-trimming) in a Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor application, update the project file as shown below. This example demonstrates how to safely configure trimming using the Grid paging feature.
57+
To [enable Intermediate Language trimming](https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming#enable-project-specific-trimming) in a Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor application, update the project file as shown below. This example demonstrates how to configure trimming using the Grid paging feature.
5858

5959
#### How to Enable Intermediate Language Trimming Safely for Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor Grid
6060

@@ -107,7 +107,7 @@ To [enable Intermediate Language trimming](https://learn.microsoft.com/en-us/dot
107107
</assembly>
108108
</linker>
109109
```
110-
3. Prevent Trimming of .NET Core Runtime Types. If your app uses reflection, LINQ expressions, or dynamic operations, consider including a LinkerConfig.xml to preserve critical system libraries. It is completely optional.
110+
3. Prevent trimming of .NET runtime types. If the app uses reflection, LINQ expressions, or dynamic operations, consider including a LinkerConfig.xml to preserve critical system libraries (optional).
111111

112112
```xml
113113
<ItemGroup>

blazor/common/best-practices.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
---
22
layout: post
3-
title: Optimizing Syncfusion Blazor App Performance | Best Practices
4-
description: Check out and learn here all about optimal strategies for enhancing Syncfusion Blazor App performance.
3+
title: Best practices to optimize Syncfusion Blazor App performance
4+
description: Learn practical ways to optimize Syncfusion Blazor Apps, including smaller packages, minimal scripts, optimized themes, lazy loading, and PreventRender.
55
platform: Blazor
6-
component: Common
6+
control: Common
77
documentation: ug
88
---
99

10-
# Best Practices for Improving Syncfusion&reg; Blazor App Performance
10+
# Best practices for optimizing Syncfusion® Blazor App performance
1111

12-
Enhancing the rendering performance of Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor apps involves implementing the following best practices.
12+
Improve rendering performance by applying the following best practices.
1313

14-
## Use Individual NuGet Packages
14+
## Use individual NuGet packages
1515

16-
Opt for individual Syncfusion<sup style="font-size:70%">&reg;</sup> NuGet packages for specific components. This approach allows you to selectively include only the necessary components, minimizing overhead. For detailed information, refer to [Benefits of Using Individual NuGet Packages](https://blazor.syncfusion.com/documentation/nuget-packages#benefits-of-using-individual-nuget-packages).
16+
Use individual Syncfusion<sup style="font-size:70%">&reg;</sup> NuGet packages for specific components. This lets the app include only what it needs and reduces download size. Learn more in [Benefits of using individual NuGet packages](https://blazor.syncfusion.com/documentation/nuget-packages#benefits-of-using-individual-nuget-packages).
1717

18-
## Reduce Script Reference Size
18+
## Reduce script reference size
1919

20-
The overall `syncfusion-blazor.min.js` script reference may be redundant. Instead, consider employing the following solutions to include only the required scripts for rendering Syncfusion<sup style="font-size:70%">&reg;</sup> components.
21-
* [Individual reference](https://blazor.syncfusion.com/documentation/common/adding-script-references#individual-control-script-reference)
22-
* [Blazor custom resource generator](https://blazor.syncfusion.com/documentation/common/custom-resource-generator)
20+
The overall `syncfusion-blazor.min.js` may include scripts the app doesn't use. Prefer referencing only the required scripts using one of the following options:
2321

24-
## Use Optimized CSS Themes
22+
- [Individual reference](https://blazor.syncfusion.com/documentation/common/adding-script-references#individual-control-script-reference)
23+
- [Blazor Custom Resource Generator (CRG)](https://blazor.syncfusion.com/documentation/common/custom-resource-generator)
2524

26-
To reduce CSS payload and improve rendering speed, use optimized CSS themes provided by Syncfusion. These themes are tailored to include only the styles required for the components you use. Learn more at Optimized CSS Themes
27-
https://blazor.syncfusion.com/documentation/appearance/themes#optimized-css-themes
28-
## Lazy Loading in Blazor WebAssembly App
25+
## Use optimized CSS themes
2926

30-
If you're using a Blazor WebAssembly app, consider implementing lazy loading to reduce the initial loading time. For guidance, refer to Microsoft's documentation on [WebAssembly lazy load assemblies](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies?view=aspnetcore-7.0) and Syncfusion's blog on [lazy loading Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor assemblies](https://www.syncfusion.com/blogs/post/lazy-loading-syncfusion-blazor-assemblies-in-a-blazor-webassembly-application.aspx).
27+
To reduce CSS payload and improve rendering speed, use optimized CSS themes that include only the styles required by the components in use. Learn more in [Optimized CSS themes](https://blazor.syncfusion.com/documentation/appearance/themes#optimized-css-themes).
3128

32-
## Utilize PreventRender Option in Blazor WebAssembly App
29+
## Lazy loading in Blazor WebAssembly App
3330

34-
In a Blazor WebAssembly app, leverage the **PreventRender** option to avoid unnecessary re-rendering of Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components. This ensures optimal performance. For reference, we have provided links for the DataGrid and PivotTable:
31+
If using a Blazor WebAssembly App, implement lazy loading to reduce initial load time. See [WebAssembly lazy load assemblies](https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies) and the Syncfusion blog on [lazy loading Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor assemblies](https://www.syncfusion.com/blogs/post/lazy-loading-syncfusion-blazor-assemblies-in-a-blazor-webassembly-application.aspx).
3532

36-
* DataGrid: [Link to WebAssembly performance documentation](https://blazor.syncfusion.com/documentation/datagrid/webassembly-performance)
37-
* PivotTable: [Link to WebAssembly performance documentation](https://blazor.syncfusion.com/documentation/pivot-table/webassembly-performance)
33+
## Use PreventRender in Blazor WebAssembly App
34+
35+
In a Blazor WebAssembly App, use the `PreventRender` option to avoid unnecessary re-rendering of Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components and improve performance. For details, see:
36+
37+
- DataGrid: [WebAssembly performance](https://blazor.syncfusion.com/documentation/datagrid/webassembly-performance)
38+
- Pivot Table: [WebAssembly performance](https://blazor.syncfusion.com/documentation/pivot-table/webassembly-performance)

0 commit comments

Comments
 (0)