Razor: Link and Script tags, enableoptimizations strips out defer
See original GitHub issueI’m submitting a [x] bug report about [x] Razor templating
Current behavior Trying to get a <script> on the page using Razor in a View…
<script defer src="//unpkg.com/@("@")github/clipboard-copy-element@latest" data-enableoptimizations="true">
</script>
But the result unexpectedly strips out defer
…
<script src="https://unpkg.com/@github/clipboard-copy-element@latest" type="text/javascript">
Expected behavior
Seems like it should leave attributes in place that it doesn’t deal with, so I would expect to see this in the resulting HTML:
<script defer src="https://unpkg.com/@github/clipboard-copy-element@latest" type="text/javascript">
Instructions to Reproduce the Problem Add the first code example above to a View/Razor file. It will work, but View Source and the “defer” is gone.
Why change the behavior?
It seems like the behavior of data-enableoptimizations
should be to only deal with things it knows about and pass through anything unknown.
Your environment
2sxc version(s): 12.2.1 Browser: all/any
- DNN: 9.09.01 Language: any/all
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Script Link in Header - EnableOptimizations Strips Attributes
Okay, so I worked it out in code using the DnnJsInclude control. ... ClientResourceManagement @{ // Add a <script> tag in the head...
Read more >Script Tag Helper in ASP.NET Core
Don't use the <script> element's defer attribute to defer loading the CDN script. The Script Tag Helper renders JavaScript that immediately ...
Read more >Efficiently load third-party JavaScript - web.dev
This post explains how to optimize the loading process of third-party scripts with the following techniques: Using the async or defer attribute ...
Read more >Integrating AngularJS with ASP.NET MVC
Render method generates multiple script tags for each item in the bundle when EnableOptimizations is set to false or when running in debug...
Read more >Stop Putting Your Script Tags At The End Of The Body
Full Video: https://youtu.be/BMuFBYw91UQ Blog Article: https://blog.webdevsimplified.com/2019-12/javascript-loading-attributes-explained ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
should be fixed in 13.03
Was fixed in 13.03