v s
v s

Reputation: 559

can I call javascript obfuscated code normally on asp.net aspx page?

I am developing web app using asp.net. I have plenty of javascript files which I want to obfuscate. I found many links on this and other sites for various tools. However following points are not clear from them

  1. Can I minify the obfuscated js file?
  2. if I obfuscate my js files before I put everything on production server what happens to all js calls in aspx pages? do they remain as it is or i have to do something? for example I have a function in js

    var a="Hello World!";
    function MsgBox(msg)
    {
        alert(msg+"\n"+a);
    }
    

.... in aspx page

    <asp:Button id="b" runat="server" onclick="MsgBox('asp.net')">

.... in above code what happens to javascript function call to MsgBox

Upvotes: 2

Views: 2169

Answers (1)

Kamyar Nazeri
Kamyar Nazeri

Reputation: 26524

Obfuscation usually minifies the script as well, however if you compress the resources no matter what (js files, css files, html codes) on the server using gzip you can save lots of bandwidth and your site loads more quickly.

As for your second question, Yes the signature of your methods remains unchanged using any kind of obfuscation

It is worth pointing out that Asp.Net 4.5 comes with built-in Bundling and Minification which saves lots of trouble with minification of JS files.

Upvotes: 1

Related Questions