Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have one snippet of javascript code, but when I compiles this code, I can not get the correct javascript.

$.ajax({
            //...
            
            error: function(abc) {
                anotherFunction(abc.responseText)
            }
        })

This parameter is missing, sometimes it is changed to n.

What I have tried:

I test all other code, it always show the wrong result. From this link
A Step by Step Guide to Bundling and Minification in ASP.NET Core[^]
Posted
Updated 1-Feb-21 2:47am
v2
Comments
Richard MacCutchan 1-Feb-21 9:10am    
You should try asking the person who wrote the tutorial.

1 solution

Minification can and will change the name of your function parameters to single characters wherever possible, to reduce the size of the minified script.

The process will also update any usages within the function, so that the behaviour remains unchanged.

If you believe that you have found a case where this doesn't happen, then report the bug to Microsoft. However, based on the simple example shown, I find it highly unlikely that the single reference to the parameter within the function would not be changed correctly.
 
Share this answer
 
Comments
rtksmithjoton123 2-Feb-21 4:32am    
Do you encounter this situation, how do you determine that it is a bug?
Richard Deeming 2-Feb-21 4:50am    
If the minification process changes the name of the parameter, but doesn't update the usage of that parameter within the function body, then it's a bug.

Eg: If it turns:
function(abc) { doSomething(abc.def); }

into:
function(n) { doSomething(abc.def); }

then it's a bug.

If it changes it to:
function(n) { doSomething(n.def); }

then it's not a bug. It hasn't changed the meaning of the code.
rtksmithjoton123 3-Feb-21 4:44am    
Thank your explanation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900