Js encryption compression bug solution

  • 2020-03-30 04:23:20
  • OfStack

This case after the simplification of the error detection method: open the IE script error, and then open the call JS HTML page, it will report the location of the missing semicolon, and then use UE to open the simplified JS file, go to the corresponding location with a semicolon, and find the corresponding location in the unsimplified JS code with a semicolon.
Such as:


var a=1
var b=2

To:


var a=1;
var b=2;

In pieces try to use braces for statements after the else
In this case, it is difficult to check the error, by using the regular expression else[a-za-z0-9]+ to find the reduced JS file, or to find the lines with comments after the else, and then find the corresponding position in the unreduced JS code with braces.
Such as:


if (a>b)
a=b;
else
b=a;

To:


if (a>b)
a=b;
else
{b=a}

In pieces try to put a semicolon after the inverse curly bracket of function
Such as:


function a() {
}
function b() {
}

To:


function a() {
};
function b() {
};

Only after the compression can solve the problem of error reporting after compression.
At the same time, pay attention to the problem of Chinese garbled code, you can not save as a file by copying and pasting.

Window. The load = function ()
{

}
So by definition, you have to have a semicolon at the end.


Related articles: