News

Blazor WebAssembly Gets Lazy Loading

Blazor enhancements show strongly in the list of ASP.NET Core updates included in this week's release of .NET 5 Preview 8, with lazy loading for the client-side component heading the list of improvements to the open source framework that allows for web development in C# instead of JavaScript.

In addition to lazy loading for Blazor WebAssembly, that list includes:

  • CSS isolation for Blazor components
  • Updated Blazor WebAssembly globalization support
  • New InputRadio Blazor component
  • Set UI focus in Blazor apps
  • IAsyncDisposable for Blazor components
  • Control Blazor component instantiation

"Lazy loading enables you to improve the load time of your Blazor WebAssembly app by deferring the download of specific app dependencies until they are required," said Daniel Roth, principal program manager, ASP.NET, in an Aug. 25 blog post. "Lazy loading may be helpful if your Blazor WebAssembly app has large dependencies that are only used for specific parts of the app."

Microsoft isn't alone in applying lazy loading to Blazor, as a GitHub project by Ivan Sanz Carasa does just that.

A Hot Topic
A Hot Topic (source: Ivan Sanz Carasa).

Developers can learn more about Microsoft's implementation of lazy loading in Blazor WebAssembly in the new guidance: Lazy load assemblies in ASP.NET Core Blazor WebAssembly.

Roth listed the Blazor enhancements along with other updates for ASP.NET Core in the new preview of .NET 5, which is scheduled to debut in November. Before that, .NET 5 -- which is now feature complete -- will see two release candidates shipping.

In explaining the Blazor-specific updates, Roth said:

  • CSS isolation for Blazor components lets developers scope CSS styles to a specific component in order to better reason about different app styles and avoid side effects that can arise from the use of global styles.
  • The updated Blazor WebAssembly globalization support is still a work in progress, with some of that work aimed at reducing the size of downloaded International Components for Unicode (ICU) payloads.
  • The new Blazor built-in InputRadio and InputRadioGroup components simplify data binding to radio button groups with integrated validation alongside the other Blazor form input components.
  • Preview 8 introduces a FocusAsync convenience method on ElementReference for setting the UI focus on that element.
  • The IAsyncDisposable interface for the asynchronous release of allocated resources is now supported in Blazor components.
  • Developers provide their own IComponentActivator service implementation in order to control how Blazor components are instantiated.
  • Developers can now programmatically set the title of a page and dynamically add link and meta tags to the HTML head in a Blazor app with new Title, Link and Meta components.
  • Protected browser storage ensures that in Blazor Server, app state data parked in local or session storage isn't changed, via two new services called ProtectedLocalStorage and ProtectedSessionStorage.

"Blazor is winning all the things!" said one developer in the post's comments section, though several others pointed out problems with failed builds and other issues.

Going forward, the Blazor Roadmap for .NET 5 indicates the first .NET 5 release candidate (RC) will address:

Other, non-Blazor updates listed by Roth in this week's post include:

  • Azure Active Directory authentication with Microsoft.Identity.Web
  • Model binding and validation with C# 9 record types
  • Improvements to DynamicRouteValueTransformer
  • Auto refresh with dotnet watch
  • Console Logger Formatter
  • JSON Console Logger

More information about all of the above and much more can be found in the post or in the release notes for .NET 5 that detail new features in ASP.NET Core and bug fixes.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events