preserveFunctionNames=false not working in MicrosoftAjaxJsMinifier

Jul 17, 2015 at 12:39 AM
Hi Taritsyn,

I set preserveFunctionNames to false in Web.config but it didn't change function names. How can I force MicrosoftAjax to change? Thanks!

function Hello() {return 'Hello';}
function World() {return ' World!';}
alert(Hello() + World());

What I got after MicrosoftAjax JS minification is still the same function name.

function Hello(){return"Hello"}function World(){return" World!"}alert(Hello()+World());
Coordinator
Jul 17, 2015 at 7:42 AM
Hello, Emyria!

Hello and World functions is global, and therefore it's name is not processed.

You need to make it local. To do this, wrap the code in a IIFE (Immediately Invoked Function Expression):
(function(){
    function Hello() {return 'Hello';}
    function World() {return ' World!';}
    alert(Hello() + World()); 
})();
Marked as answer by Taritsyn on 3/9/2016 at 3:27 AM