diff --git a/src/JS.php b/src/JS.php index e08e6dc..ea10b81 100644 --- a/src/JS.php +++ b/src/JS.php @@ -415,6 +415,9 @@ class JS extends Minify $content = preg_replace('/\btrue\b/', '!0', $content); $content = preg_replace('/\bfalse\b/', '!1', $content); + // for(;;) is exactly the same as while(true) + $content = preg_replace('/\bwhile\(!0\)/', 'for(;;)', $content); + return $content; } } diff --git a/tests/js/JSTest.php b/tests/js/JSTest.php index 8f9559e..2930fcb 100644 --- a/tests/js/JSTest.php +++ b/tests/js/JSTest.php @@ -388,6 +388,12 @@ if(e.which==40&&index<$items.length-1)index++', 'array["dont-replace"].key2', ); + // shorten bools + $tests[] = array( + 'while(true){break}', + 'for(;;){break}', + ); + // https://github.com/matthiasmullie/minify/issues/10 $tests[] = array( '// first mutation patch