Home > Web Front-end > JS Tutorial > js encryption compression bug solution_Basic knowledge

js encryption compression bug solution_Basic knowledge

WBOY
Release: 2016-05-16 16:30:31
Original
1293 people have browsed it

The method to check the error after streamlining in this situation: Open the script error prompt of IE, and then open the HTML page that calls JS. It will report the location of the missing semicolon, then use UE to open the streamlining JS file and go to the corresponding Add a semicolon to the position, then find the corresponding position in the unreduced JS code and add a semicolon.
For example:

Copy code The code is as follows:

var a=1
var b=2

changed to:

Copy code The code is as follows:

var a=1;
var b=2;

◆Try to use braces
in the statement after else In this case, it is more troublesome to check the error. Use the regular expression else[a-zA-Z0-9] to find the streamlined JS file, or check whether there is a commented line after else, and then find the corresponding line in the unreduced JS code. Add braces at the position.
For example:

Copy code The code is as follows:

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

changed to:

Copy code The code is as follows:

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

◆Try to add a semicolon after the inverse brace of function
For example:

Copy code The code is as follows:

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

changed to:

Copy code The code is as follows:

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

In this way, the problem of error reporting after compression can be solved after compression.
At the same time, pay attention to the problem of garbled Chinese characters. You can use copy and paste instead of saving as a file.

window.load = function()
{

}
If defined this way, there must be a semicolon at the end.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template