Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to the Documentation on Importing Javascript modules that the script file is automatically downloaded when the Page is Rendered #34414

Open
gregoryagu opened this issue Dec 26, 2024 · 1 comment
Assignees
Labels

Comments

@gregoryagu
Copy link

gregoryagu commented Dec 26, 2024

Description

There is a feature that is not described in the docs on Javascript interop. This feature is that this code will automatically download the js file when the page is navigated to. In other words, there is no need to add a script tag to the App.razor file. In fact, if you do add it, it will not download successfully. To see this issue, uncomment the script tag in App.razor to force the browser to attempt to download it.

module = await JS.InvokeAsync<IJSObjectReference>("import",
    "./Components/Pages/CallDotnet1.razor.js");

Here is a simple Repro: https://github.com/gregoryagu/CallDotNetFromJs/

I would suggest adding text to describe this feature so that the user does not try to manually add the script tag, and also it is a really cool feature.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/location-of-javascript?view=aspnetcore-9.0#load-a-script-from-an-external-javascript-file-js-collocated-with-a-component

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/javascript-interoperability/location-of-javascript.md

Document ID

af240267-89c0-f192-7807-cf426001ad8d

Article author

@guardrex

Related Issues

Copy link
Contributor

🍂🎁 Happy Holidays! ❄️⛄

This issue has been marked for triage on the Blazor Docs GitHub project, and I'll respond as soon as I return from the holiday vacation after New Year's.

We only work on documentation on this repo. If you need product support, close this issue and seek assistance through one or more of the following support channels:

If you think that you found a potential bug in the framework or have product feedback, close this issue and open a new issue for the ASP.NET Core product unit at dotnet/aspnetcore issues. Bug reports require a clear explanation of the problem, usually including a minimal repro project placed on GitHub for the product unit engineers to download and run. If you determine with the product unit that it isn't a bug but merely requires documentation, please re-open this docs issue and place a cross-link to your engineering issue discussion.

For problems or feedback on Visual Studio, close this issue and use the Report a Problem or Suggest a Feature processes from within VS, which open internal issues for the VS product unit. For more information, see Visual Studio Feedback.

For problems with Visual Studio Code, close this issue and ask for support on community support forums. For bug reports and product feedback, open an issue on the microsoft/vscode GitHub repo.

💃🕺🥳 Happy New Year! 🎈🎆🍾🥂🎉 See you in 2025!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Triage
Development

No branches or pull requests

2 participants