Soenneker.Blazor.Utils.ResourceLoader 4.0.1633

Prefix Reserved
dotnet add package Soenneker.Blazor.Utils.ResourceLoader --version 4.0.1633
                    
NuGet\Install-Package Soenneker.Blazor.Utils.ResourceLoader -Version 4.0.1633
                    
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="Soenneker.Blazor.Utils.ResourceLoader" Version="4.0.1633" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Blazor.Utils.ResourceLoader" Version="4.0.1633" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Blazor.Utils.ResourceLoader" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Blazor.Utils.ResourceLoader --version 4.0.1633
                    
#r "nuget: Soenneker.Blazor.Utils.ResourceLoader, 4.0.1633"
                    
#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.
#:package Soenneker.Blazor.Utils.ResourceLoader@4.0.1633
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Blazor.Utils.ResourceLoader&version=4.0.1633
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Utils.ResourceLoader&version=4.0.1633
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Blazor.Utils.ResourceLoader

A Blazor JavaScript interop for dynamically loading scripts, styles, and modules

Overview

The ResourceLoader class is designed to manage the loading and initialization of scripts, styles, and JavaScript modules in a Blazor application. It provides methods to asynchronously load scripts and styles, wait for variables to be available, and manage the lifecycle of JavaScript modules.

It ensures that each resource is only loaded once (through this interop), even with multiple concurrent calls.

Table of Contents

Installation

dotnet add package Soenneker.Blazor.Utils.ResourceLoader

Usage

Loading Scripts

To load a script, use the LoadScript method. It injects the file into the DOM.

await resourceLoader.LoadScript("https://example.com/script.js");

LoadScriptAndWaitForVariable is also available as a legacy fallback for third-party scripts that expose globals instead of ES module exports:

await resourceLoader.LoadScriptAndWaitForVariable("https://example.com/script.js", "variableName");

Loading Styles

To load a style, use the LoadStyle method. It injects the file into the DOM.

await resourceLoader.LoadStyle("https://example.com/style.css");

Importing Modules

To import a JavaScript module, use the ImportModule method:

var module = await resourceLoader.ImportModule("moduleName");

ImportModule already waits for the ES module import to complete, so Soenneker-owned interops should import the module directly and invoke its exports.

Waiting for Variables

To wait for a JavaScript global to be available, use the WaitForVariable method:

await resourceLoader.WaitForVariable("variableName");

Disposing Modules

Be sure to dispose of a module after you're done interacting with it. To dispose of a JavaScript module, use the DisposeModule method:

await resourceLoader.DisposeModule("moduleName");
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (31)

Showing the top 5 NuGet packages that depend on Soenneker.Blazor.Utils.ResourceLoader:

Package Downloads
Soenneker.Blazor.TomSelect

A Blazor interop library for the select user control library, Tom Select

Soenneker.Blazor.FilePond

A Blazor interop library for the file upload library FilePond

Soenneker.Blazor.Clarity

A small Blazor interop library that sets up Microsoft Clarity

Soenneker.Blazor.Masonry

A lightweight, responsive Blazor component for Masonry (the cascading grid layout library) — perfect for image grids, cards, and dynamic content.

Soenneker.Blazor.LogJson

A Blazor interop library that logs JSON (like HTTP requests/responses) within the browser

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1633 317 3/23/2026
4.0.1632 200 3/22/2026
4.0.1631 76 3/22/2026
4.0.1630 397 3/22/2026
4.0.1629 3,075 3/14/2026
4.0.1628 602 3/14/2026
4.0.1627 613 3/13/2026
4.0.1626 2,448 3/12/2026
4.0.1625 448 3/12/2026
4.0.1624 448 3/12/2026
4.0.1623 1,247 3/12/2026
4.0.1622 2,207 3/11/2026
4.0.1621 677 3/11/2026
4.0.1620 549 3/11/2026
4.0.1619 923 3/11/2026
4.0.1618 565 3/11/2026
4.0.1617 789 3/11/2026
4.0.1616 620 3/10/2026
4.0.1615 510 3/10/2026
4.0.1614 474 3/10/2026
Loading failed

Update dependency Soenneker.Blazor.Utils.JsVariable to 4.0.1272 (#1973)