Soenneker.Blazor.Utils.ResourceLoader 4.0.1646

Prefix Reserved
dotnet add package Soenneker.Blazor.Utils.ResourceLoader --version 4.0.1646
                    
NuGet\Install-Package Soenneker.Blazor.Utils.ResourceLoader -Version 4.0.1646
                    
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.1646" />
                    
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.1646" />
                    
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.1646
                    
#r "nuget: Soenneker.Blazor.Utils.ResourceLoader, 4.0.1646"
                    
#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.1646
                    
#: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.1646
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Blazor.Utils.ResourceLoader&version=4.0.1646
                    
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");

To load an ES module script tag, use LoadModuleScript:

await resourceLoader.LoadModuleScript("https://example.com/module.js");

If that module assigns a global and you need to wait for it, use:

await resourceLoader.LoadModuleScriptAndWaitForVariable("https://example.com/module.js", "myGlobal");

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.

To import an external ES module by absolute URI, use ImportExternalModule:

var module = await resourceLoader.ImportExternalModule("https://cdn.jsdelivr.net/npm/some-package/+esm");

This is useful for ESM-first libraries that do not expose browser globals.

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");

External modules imported by URL can also be disposed:

await resourceLoader.DisposeExternalModule("https://cdn.jsdelivr.net/npm/some-package/+esm");
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 (20)

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.Masonry

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

Soenneker.Blazor.Turnstile

A Blazor interop library for Cloudflare Turnstile

Soenneker.Blazor.DataTables

A Blazor interop library for DataTables

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1646 648 4/8/2026
4.0.1645 65 4/8/2026
4.0.1644 193 4/8/2026
4.0.1643 239 4/8/2026
4.0.1642 207 4/8/2026
4.0.1641 1,063 4/7/2026
4.0.1640 907 4/6/2026
4.0.1639 79 4/6/2026
4.0.1638 121 4/6/2026
4.0.1637 83 4/6/2026
4.0.1636 1,265 4/5/2026
4.0.1635 1,679 4/1/2026
4.0.1634 969 3/31/2026
4.0.1633 2,819 3/23/2026
4.0.1632 351 3/22/2026
4.0.1631 148 3/22/2026
4.0.1630 740 3/22/2026
4.0.1629 3,779 3/14/2026
4.0.1628 608 3/14/2026
4.0.1627 624 3/13/2026
Loading failed

misc