Does Asp.Net MVC 4 package not provide <script> section attributes?

My question is:

How can I create a <script> section with attributes using Asp.Net Mvc package optimization?

I need to be able to get something like this in my html result:

 <script type="text/javascript" src="myjavascript.js" charset="UTF-8"></script> 

The reason is because my "myjavascript.js" contains unicode characters, and in the browser I have square characters instead of the source text.

Can I do this with Asp.Net package optimization classes?

"Quick Google Search" says I can’t.

Thank you for your responses!

+4
source share
2 answers

I am afraid that you cannot do this. But you can save the javascript file as UTF-8 using the specification, and your site also uses UTF-8:

 <meta charset="utf-8" /> 

Now the unicode characters stored in your javascript file will display correctly.

+2
source

You can also use the RenderFormat method to configure how the Scripts helper displays tags:

Generate an attribute type in a "script" tag when using Scripts.Render in ASP.NET MVC 4

+1
source

Source: https://habr.com/ru/post/1469165/


All Articles