{"id":15092948,"url":"https://github.com/soenneker/soenneker.blazor.utils.resourceloader","last_synced_at":"2026-04-22T04:05:13.408Z","repository":{"id":245762601,"uuid":"819168812","full_name":"soenneker/soenneker.blazor.utils.resourceloader","owner":"soenneker","description":"A Blazor JavaScript module for dynamically loading scripts and styles","archived":false,"fork":false,"pushed_at":"2026-04-21T11:00:32.000Z","size":2167,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-21T13:06:38.102Z","etag":null,"topics":["blazor","csharp","dotnet","import","javascript","module","resourceloader","script","style","util","utils"],"latest_commit_sha":null,"homepage":"https://soenneker.com","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soenneker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"soenneker","thanks_dev":"soenneker"}},"created_at":"2024-06-24T01:01:56.000Z","updated_at":"2026-04-21T11:00:37.000Z","dependencies_parsed_at":"2026-04-21T13:02:43.914Z","dependency_job_id":null,"html_url":"https://github.com/soenneker/soenneker.blazor.utils.resourceloader","commit_stats":{"total_commits":339,"total_committers":4,"mean_commits":84.75,"dds":0.07079646017699115,"last_synced_commit":"10dd18e49774759fadb5194d55539ea9a654a471"},"previous_names":["soenneker/soenneker.blazor.utils.resourceloader"],"tags_count":204,"template":false,"template_full_name":null,"purl":"pkg:github/soenneker/soenneker.blazor.utils.resourceloader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.resourceloader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.resourceloader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.resourceloader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.resourceloader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soenneker","download_url":"https://codeload.github.com/soenneker/soenneker.blazor.utils.resourceloader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soenneker%2Fsoenneker.blazor.utils.resourceloader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32120408,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","csharp","dotnet","import","javascript","module","resourceloader","script","style","util","utils"],"created_at":"2024-09-25T11:01:55.249Z","updated_at":"2026-04-22T04:05:13.402Z","avatar_url":"https://github.com/soenneker.png","language":"C#","funding_links":["https://github.com/sponsors/soenneker","https://thanks.dev/soenneker"],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/nuget/v/soenneker.blazor.utils.resourceloader.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.utils.resourceloader/)\n[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.utils.resourceloader/publish-package.yml?style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.utils.resourceloader/actions/workflows/publish-package.yml)\n[![](https://img.shields.io/nuget/dt/soenneker.blazor.utils.resourceloader.svg?style=for-the-badge)](https://www.nuget.org/packages/soenneker.blazor.utils.resourceloader/)\n[![](https://img.shields.io/github/actions/workflow/status/soenneker/soenneker.blazor.utils.resourceloader/codeql.yml?label=CodeQL\u0026style=for-the-badge)](https://github.com/soenneker/soenneker.blazor.utils.resourceloader/actions/workflows/codeql.yml)\n\n# ![](https://user-images.githubusercontent.com/4441470/224455560-91ed3ee7-f510-4041-a8d2-3fc093025112.png) Soenneker.Blazor.Utils.ResourceLoader\n### A Blazor JavaScript interop for dynamically loading scripts, styles, and modules\n\n## Overview\n\nThe `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.\n\nIt ensures that each resource is only loaded once (through this interop), even with multiple concurrent calls.\n\n## Table of Contents\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Loading Scripts](#loading-scripts)\n  - [Loading Styles](#loading-styles)\n  - [Importing Modules](#importing-modules)\n  - [Waiting for Variables](#waiting-for-variables)\n  - [Disposing Modules](#disposing-modules)\n\n## Installation\n\n```\ndotnet add package Soenneker.Blazor.Utils.ResourceLoader\n```\n\n## Usage\n\n### Loading Scripts\n\nTo load a script, use the `LoadScript` method. It injects the file into the DOM.\n\n```csharp\nawait resourceLoader.LoadScript(\"https://example.com/script.js\");\n```\n\n`LoadScriptAndWaitForVariable` is also available as a legacy fallback for third-party scripts that expose globals instead of ES module exports:\n\n```csharp\nawait resourceLoader.LoadScriptAndWaitForVariable(\"https://example.com/script.js\", \"variableName\");\n```\n\nTo load an ES module script tag, use `LoadModuleScript`:\n\n```csharp\nawait resourceLoader.LoadModuleScript(\"https://example.com/module.js\");\n```\n\nIf that module assigns a global and you need to wait for it, use:\n\n```csharp\nawait resourceLoader.LoadModuleScriptAndWaitForVariable(\"https://example.com/module.js\", \"myGlobal\");\n```\n\n### Loading Styles\n\nTo load a style, use the `LoadStyle` method. It injects the file into the DOM.\n\n```csharp\nawait resourceLoader.LoadStyle(\"https://example.com/style.css\");\n```\n\n### Importing Modules\n\nTo import a JavaScript module, use the `ImportModule` method:\n\n```csharp\nvar module = await resourceLoader.ImportModule(\"moduleName\");\n```\n\n`ImportModule` already waits for the ES module import to complete, so Soenneker-owned interops should import the module directly and invoke its exports.\n\nTo import an external ES module by absolute URI, use `ImportExternalModule`:\n\n```csharp\nvar module = await resourceLoader.ImportExternalModule(\"https://cdn.jsdelivr.net/npm/some-package/+esm\");\n```\n\nThis is useful for ESM-first libraries that do not expose browser globals.\n\n### Waiting for Variables\n\nTo wait for a JavaScript global to be available, use the `WaitForVariable` method:\n\n```csharp\nawait resourceLoader.WaitForVariable(\"variableName\");\n```\n\n### Disposing Modules\n\nBe sure to dispose of a module after you're done interacting with it. To dispose of a JavaScript module, use the `DisposeModule` method:\n\n```csharp\nawait resourceLoader.DisposeModule(\"moduleName\");\n```\n\nExternal modules imported by URL can also be disposed:\n\n```csharp\nawait resourceLoader.DisposeExternalModule(\"https://cdn.jsdelivr.net/npm/some-package/+esm\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.resourceloader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.resourceloader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoenneker%2Fsoenneker.blazor.utils.resourceloader/lists"}