| 1 | <?php |
||
| 3 | class SugarMin { |
||
|
|
|||
| 4 | |||
| 5 | /** |
||
| 6 | * jsParser will take javascript source code and minify it. |
||
| 7 | * |
||
| 8 | * Note: There is a lot of redundant code since both passes |
||
| 9 | * operate similarly but with slight differences. It will probably |
||
| 10 | * be a good idea to refactor the code at a later point when it is stable. |
||
| 11 | * |
||
| 12 | * JSParser will perform 3 passes on the code. Pass 1 takes care of single |
||
| 13 | * line and mult-line comments. Pass 2 performs some sanitation on each of the lines |
||
| 14 | * and pass 3 works on stripping out unnecessary spaces. |
||
| 15 | * |
||
| 16 | * @param string $js |
||
| 17 | * @param string $currentOptions |
||
| 18 | * @return void |
||
| 19 | */ |
||
| 20 | 1 | private function __construct($text, $compression) { |
|
| 24 | |||
| 25 | /** |
||
| 26 | * Entry point function to minify javascript. |
||
| 27 | * |
||
| 28 | * @param string $js Javascript source code as a string. |
||
| 29 | * @param string $compression Compression option. {light, deep}. |
||
| 30 | * @return string $output Output javascript code as a string. |
||
| 31 | */ |
||
| 32 | 1 | static public function minify($js, $compression = 'light') { |
|
| 43 | |||
| 44 | 1 | protected function jsParser() { |
|
| 48 | } |
||
| 49 |