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

Js Isolation for Asp.Net Core Web Application for .cshtml files #30850

Closed
mojtabakaviani opened this issue Mar 11, 2021 · 4 comments
Closed

Js Isolation for Asp.Net Core Web Application for .cshtml files #30850

mojtabakaviani opened this issue Mar 11, 2021 · 4 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@mojtabakaviani
Copy link

Thanks for add #25713 please add support for js Isolation for Asp.Net Core Web Application for .cshtml files, same css simply add a .cshtml.js to view folders.

@Pilchie Pilchie added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Mar 11, 2021
@javiercn
Copy link
Member

@mojtabakaviani thanks for contacting us.

What scenario do you have in mind for this in the context of a web app?

@mojtabakaviani
Copy link
Author

Usually in the pages needs to add javascript for working with DOM. Now can use @section tag to add scripts to render to layout, but if have many code lines and string literals, formatting not work perfectly and not minifying and load scripts every page called. good idea to use separated js files and minifying or just many developers like to use separated js and css files for pages. I now use my method's that create js files in wwwroot/js folder and linked to pages but if asp.net core native support css and js isolation in separated files and even can auto generating and loading .cshtml.min.css and .cshtml.min.js with versioning for production mode, it is very good news.

@javiercn
Copy link
Member

@mojtabakaviani thanks for the additional details.

Our support for JS isolation on Blazor is limited to the fact that we support the import keywork via JS interop and that we return a JSObjectReference back.

None of these things apply to MVC. You can already achieve what you want without support from the runtime by using
<script type="module" src="path-to-module.js"></script> on your cshtml file and putting the js file within the wwwroot folder at your desired path.

Modules will be loaded once, will bring in their dependencies via imports and will render asynchronously.

@javiercn javiercn added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question labels Mar 15, 2021
@ghost ghost added the Status: Resolved label Mar 15, 2021
@ghost
Copy link

ghost commented Mar 16, 2021

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Mar 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Apr 15, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants