Skip to content

Remove inline scripts from project templates #11111

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

Closed
mkArtakMSFT opened this issue Jun 11, 2019 · 7 comments
Closed

Remove inline scripts from project templates #11111

mkArtakMSFT opened this issue Jun 11, 2019 · 7 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug.

Comments

@mkArtakMSFT
Copy link
Member

We should move all the inline scripts (if any) to separate js files.

@mkArtakMSFT mkArtakMSFT added bug This issue describes a behavior which is not expected - a bug. PRI: 1 - Required area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Jun 11, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview8 milestone Jun 11, 2019
@ryanbrandenburg
Copy link
Contributor

I'm not aware of any instances of that offhand, was there an inciting incident for this?

@rynowak
Copy link
Member

rynowak commented Jun 13, 2019

I believe <script ...> tag helper uses inline scripts.

@isaacrlevin
Copy link
Contributor

@mkArtakMSFT do you have an example? I just searched the repo and didn't see any

@mkArtakMSFT
Copy link
Member Author

Looks like indeed the current templates don't have a <script> tag in the content. At least not at the moment. As for the tag-helper, that's right, it does produce the tag so that may be something we will revisit during 3.1.

@mkArtakMSFT mkArtakMSFT modified the milestones: 3.1.0, 3.1.0-preview1 Aug 27, 2019
@ryanbrandenburg
Copy link
Contributor

It's still not clear to me what the work item is here. The only instance I see of a <script tag having tag-helpery attributes still results in a script tag pointing to the file rather than an inlined script.

@mkArtakMSFT
Copy link
Member Author

I'm closing this in that case. Thanks for confirming, @ryanbrandenburg

@blowdart
Copy link
Contributor

blowdart commented Oct 4, 2019

OK bringing this back up for #14104 (comment)

@rynowak says "We already have this, it isn't new", and the suggested fix, fallback is an inline script, specifically

<script>!function(a,b,c,d){var e,f=document,g=f.getElementsByTagName("SCRIPT"),h=g[g.length-1].previousElementSibling,i=f.defaultView&&f.defaultView.getComputedStyle?f.defaultView.getComputedStyle(h):h.currentStyle;if(i&&i[a]!==b)for(e=0;e<c.length;e++)f.write('<link href="'+c[e]+'" '+d+"/>")}("display","none",["\/lib\/normalize.min.css"], "rel=\u0022stylesheet\u0022 ");</script>

If this is unique to the LinkTagHelper then it only needs fixed there, but if it's a tag helper wide feature then we need to look at every tag helper and change them to use a different approach, like script registration and an output of all the registered scripts in a virtual .js file.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
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 bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

No branches or pull requests

5 participants