Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Razor: Link and Script tags, enableoptimizations strips out defer

See original GitHub issue

I’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="//"@")github/clipboard-copy-element@latest" data-enableoptimizations="true">

But the result unexpectedly strips out defer

<script src="" 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="" 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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

iJungleboycommented, Mar 17, 2022

should be fixed in 13.03

iJungleboycommented, Mar 21, 2022

Was fixed in 13.03

Read more comments on GitHub >

github_iconTop 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 -
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: Blog Article: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found