Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does minification affect JavaScript functionality?

I'm thinking of using bundling for my group's ASP.NET MVC3 project, and I can't break it cause I'm a junior dev.

Does JavaScript minification affect JavaScript function names - i.e. can I still call the functions that I minify by the same name from inline code? Also, does it ever effect how code behaves - or is JavaScript functionality and order fully preserved?

like image 932
John Doe Avatar asked Apr 10 '26 08:04

John Doe


1 Answers

Bundling and Minification is not going to break your code by renaming your function names. The minification optimizes code through removing unnecessary whitespace, removing comments, and shortening variable names to one character.

Say you make this function:

function BigHonkingFunctionName(bigvariablename1, bigvariablename2) {
    //I love this function
    alert(bigvariablename1 + " " + bigvariablename2);
}

The minified result will be:

function BigHonkingFunctionName(n,t){alert(n+" "+t)}

So as you see, it won't impact how you call or use the function.

Reading on Bundling and Minification.

like image 172
MikeSmithDev Avatar answered Apr 12 '26 21:04

MikeSmithDev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!