Search code examples
asp.net-mvc-4bundleasp.net-optimization

Asp.Net MVC 4 bundle don't provide <script> section attributes?


My actual question is:

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

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

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

The reason is that my "myjavascript.js" contains unicode characters and in browser i've got square symbols instead of my original text.

Can I do that with Asp.Net bundle optimization classes?

"Fast googling" says that I can't.

Thanks for your answers!


Solution

  • I am afraid that you cannot do that. But you could save the javascript file as UTF-8 with BOM and have your site also use UTF-8:

    <meta charset="utf-8" />
    

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