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

Razor: Link and Script tags, enableoptimizations strips out defer #2454

Closed
jeremy-farrance opened this issue Jun 12, 2021 · 6 comments
Closed
Assignees

Comments

@jeremy-farrance
Copy link
Sponsor

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="//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
@iJungleboy
Copy link
Contributor

As of now data-enableoptimizations picks up the tag and tries to merge it with DNNs Client-Dependency Framework.

If you use "defer" I think there is no reason to use data-enableoptimization, since that is kind of better than the older Client-Dependency approach.

What do you think?

@jeremy-farrance
Copy link
Sponsor Author

Yeah, also, I realize now the problem is not really yours since you are just calling Dnn's RegisterScript() and that function is actually stripping it out.

I do agree with what you said, but the optimizations also eliminate dupes which are likely with multiple 2sxc Views on the same page.

@iJungleboy
Copy link
Contributor

@jeremy-farrance Gotcha. I'll need some time thinking about this. We're currently implementing something related to this called turnOn - http://r.2sxc.org/turnon. I would be curious to hear your thoughts on that. Maybe post thoughts related to turnOn on #2458

@jeremy-farrance
Copy link
Sponsor Author

So is this solved recently?

@iJungleboy
Copy link
Contributor

should be fixed in 13.03

@iJungleboy
Copy link
Contributor

Was fixed in 13.03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants