Excubo.Blazor.ScriptInjection 2.0.1

There is a newer version of this package available.
See the version list below for details.
Install-Package Excubo.Blazor.ScriptInjection -Version 2.0.1
dotnet add package Excubo.Blazor.ScriptInjection --version 2.0.1
<PackageReference Include="Excubo.Blazor.ScriptInjection" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Excubo.Blazor.ScriptInjection --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Excubo.Blazor.ScriptInjection, 2.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Excubo.Blazor.ScriptInjection as a Cake Addin
#addin nuget:?package=Excubo.Blazor.ScriptInjection&version=2.0.1

// Install Excubo.Blazor.ScriptInjection as a Cake Tool
#tool nuget:?package=Excubo.Blazor.ScriptInjection&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

This library brings the script tag to Blazor. Since components can occur any number of times, the usage of script tags in components is usually frowned upon. The Script component in Excubo.Blazor.ScriptInjection is different, as it makes sure that the source file is only put into the page's body once.

This can be used to lazily load javascript sources for any component that requires javascript. As a component library author, you can use this to relieve your users of the burden of adding script tags to their pages' <head>. Simply add <Script Src="_content/My.Library/code.js"> to any component in your library that requires that file. Excubo.Blazor.ScriptInjection makes sure the script gets loaded once and only once, regardless of how many components you have, and regardless of how many components your users use.

Usage

1. Add ScriptInjection to your services
    //...
    //using Excubo.Blazor.ScriptInjection;
    services.AddScriptInjection();
    //...
2. Use the Script component
<h3>My component requiring some js</h3>
<Script Src="path/to/code.js" Async="true" Defer="false" />

Note: Async and Defer are false by default. It is recommended to use these options wherever possible to improve page performance.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.1.0 194 11/9/2021
3.0.47 191 10/22/2021
3.0.45 195 9/15/2021
3.0.37 223 7/19/2021
3.0.33 130 6/11/2021
3.0.29 117 5/12/2021
3.0.25 578 4/7/2021
3.0.21 126 3/9/2021
3.0.17 149 3/3/2021
3.0.15 207 2/10/2021
3.0.11 199 1/13/2021
3.0.7 197 12/9/2020
3.0.5 185 11/13/2020
3.0.4 177 11/10/2020
3.0.3 3,697 10/13/2020
3.0.2 1,695 9/8/2020
3.0.1 1,474 8/12/2020
3.0.0 302 8/5/2020
2.0.2 1,319 6/28/2020
2.0.1 257 6/25/2020
2.0.0 239 6/25/2020
1.0.5 230 6/15/2020
1.0.4 222 5/14/2020
1.0.3 242 5/13/2020
1.0.2 243 5/13/2020
1.0.1 253 4/28/2020
1.0.0 313 3/31/2020