PHP 클래스 MatthiasMullie\Minify\JS
This source file can be used to minify Javascript files.
The class is documented in the file itself. If you find any bugs help me out and report them. Reporting can be done by sending an email to
[email protected].
If you report a bug, make sure you give me enough information (include your code).
License
Copyright (c) 2012, Matthias Mullie. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
파일 보기
프로젝트 열기: matthiasmullie/minify
1 사용 예제들
보호된 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$keywordsAfter |
string[] |
..>
before them. Some end of lines are not the end of a statement, like when
continued by one of these keywords on the newline.
E.g.: we shouldn't insert a ; before this instanceof
variable
instanceof String
Will be loaded from /data/js/keywords_after.txt |
|
$keywordsBefore |
string[] |
..>
after them. Some end of lines are not the end of a statement, like with
these keywords.
E.g.: we shouldn't insert a ; after this else
else
console.log('this is quite fine')
Will be loaded from /data/js/keywords_before.txt |
|
$keywordsReserved |
string[] |
Will be loaded from /data/js/keywords_reserved.txt. |
|
$operators |
string[] |
Will be loaded from /data/js/operators.txt |
|
$operatorsAfter |
string[] |
..> before
them. Some end of lines are not the end of a statement, like when
continued by one of these operators on the newline.
Note: Most operators are fine, we've only removed ), ], ++ and --.
++ & -- have to be joined with the value they're in-/decrementing.
) & ] are "special" in that they have lots or usecases. () for example
is used for function calls, for grouping, in if () and for (), ...
Will be loaded from /data/js/operators_after.txt |
|
$operatorsBefore |
string[] |
..> after
them. Some end of lines are not the end of a statement, like with these
operators.
Note: Most operators are fine, we've only removed !, ++ and --.
There can't be a newline separating ! and whatever it is negating.
++ & -- have to be joined with the value they're in-/decrementing.
Will be loaded from /data/js/operators_before.txt |
|
공개 메소드들
보호된 메소드들
메소드 상세
Perform JS optimizations.
public execute ( string[optional] $path = null ) : string |
$path |
string[optional] |
|
리턴 |
string |
The minified data |
getKeywordsForRegex()
보호된 메소드
This will prepare the given array by escaping all characters.
getOperatorsForRegex()
보호된 메소드
This will prepare the given array by escaping all characters.
propertyNotation()
보호된 메소드
Replaces all occurrences of array['key'] by array.key.
Replaces true & false by !0 and !1.
stripWhitespace()
보호된 메소드
We won't strip *all* whitespace, but as much as possible. The thing that
we'll preserve are newlines we're unsure about.
JavaScript doesn't require statements to be terminated with a semicolon.
It will automatically fix missing semicolons with ASI (automatic semi-
colon insertion) at the end of line causing errors (without semicolon.)
Because it's sometimes hard to tell if a newline is part of a statement
that should be terminated or not, we'll just leave some of them alone.
프로퍼티 상세
$keywordsAfter 보호되어 있는 프로퍼티
..>
before them. Some end of lines are not the end of a statement, like when
continued by one of these keywords on the newline.
E.g.: we shouldn't insert a ; before this instanceof
variable
instanceof String
Will be loaded from /data/js/keywords_after.txt
protected string[] $keywordsAfter |
리턴 |
string[] |
|
$keywordsBefore 보호되어 있는 프로퍼티
..>
after them. Some end of lines are not the end of a statement, like with
these keywords.
E.g.: we shouldn't insert a ; after this else
else
console.log('this is quite fine')
Will be loaded from /data/js/keywords_before.txt
protected string[] $keywordsBefore |
리턴 |
string[] |
|
$keywordsReserved 보호되어 있는 프로퍼티
Will be loaded from /data/js/keywords_reserved.txt.
protected string[] $keywordsReserved |
리턴 |
string[] |
|
Will be loaded from /data/js/operators.txt
protected string[] $operators |
리턴 |
string[] |
|
$operatorsAfter 보호되어 있는 프로퍼티
..> before
them. Some end of lines are not the end of a statement, like when
continued by one of these operators on the newline.
Note: Most operators are fine, we've only removed ), ], ++ and --.
++ & -- have to be joined with the value they're in-/decrementing.
) & ] are "special" in that they have lots or usecases. () for example
is used for function calls, for grouping, in if () and for (), ...
Will be loaded from /data/js/operators_after.txt
protected string[] $operatorsAfter |
리턴 |
string[] |
|
$operatorsBefore 보호되어 있는 프로퍼티
..> after
them. Some end of lines are not the end of a statement, like with these
operators.
Note: Most operators are fine, we've only removed !, ++ and --.
There can't be a newline separating ! and whatever it is negating.
++ & -- have to be joined with the value they're in-/decrementing.
Will be loaded from /data/js/operators_before.txt
protected string[] $operatorsBefore |
리턴 |
string[] |
|