AspNetCore.Docs
AspNetCore.Docs copied to clipboard
Can we add some concrete examples for JavaScript initializers in this page?
[EDIT by guardrex to change the metadata to point to the Startup topic, where we can place the examples with existing ones.]
Examples are:
- Ensuring that your library is loaded before Blazor Starts.
- Automatically loading the scripts that your library needs.
- Ensuring that Blazor has been initialized before calling into it from your library.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: ad891f84-d11e-e334-fcdc-b55c5171fca4
- Version Independent ID: 11f8db3d-9988-e0a1-89c5-c3552ee47b93
- Content: ASP.NET Core Blazor startup
- Content Source: aspnetcore/blazor/fundamentals/startup.md
- Product: aspnet-core
- Technology: aspnetcore-fundamentals
- GitHub Login: @guardrex
- Microsoft Alias: riande
I'm changing the metadata for this b/c this was classified as a fundamental startup concept and placed in the Startup doc at ...
https://docs.microsoft.com/en-us/aspnet/core/blazor/fundamentals/startup?view=aspnetcore-6.0#javascript-initializers
... which is cross-linked from the JS interop topic. I think I'll adjust the cross-link to make it more obvious in the JS interop overview section.
We'll add the scenario examples to the Startup topic.
... and there's an orphan scenario that could either be moved or doubled in an INCLUDE file to appear in both places ...
https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/?view=aspnetcore-6.0#inject-a-script-after-blazor-starts
Note to self: I've isolated a group of PU repo dev issues that pertain to this. See YOUR 🦖 "JSinit #26363" bookmark folder!
I'm going to place my notes here and mark this back off of In progress to P1 until I get a clearer understanding for each ask. Right now, here are the directions that I was thinking ...
-
Ensuring that your library is loaded before Blazor Starts.
Covered by loading a script in
beforeStart
. -
Automatically loading the scripts that your library needs.
Load them in order in
beforeStart
.Do you want to add the approach for modules of using an
import
statement ... and if so ...(a) What should the doc say about adding an
import
statement to the top of the*.lib.module.js
file? ... anything in particular about it?(b) Using a dynamic
import({MODULE PATH});
statement withinbeforeStart
? ... anything in particular? -
Ensuring that Blazor has been initialized before calling into it from your library.
This doesn't just mean calling the library's initialization FN from
afterStarted
? I guess I'm not clear on where/when you mean for the "calling into it" part of that. -
Another ? ...
Does the IIFE pattern play a role in any JS initializer scnearios?
-
Another ? ...
Should the guidance state that it's OK for a dev to export custom JS FNs from within the
*.lib.module.js
file SxS withbeforeStart
/afterStarted
?