]> git.joonet.de Git - adminer.git/commitdiff
Compile: JsShrink -> Terser terser origin/terser
authorJakub Vrana <jakub@vrana.cz>
Mon, 7 Apr 2025 11:36:04 +0000 (13:36 +0200)
committerJakub Vrana <jakub@vrana.cz>
Mon, 7 Apr 2025 12:58:19 +0000 (14:58 +0200)
.gitmodules
compile.php

index 04841dce1193950c910992df1eec38c60510acbc..0851cc5509063c5a1832c096fcc14806337f923b 100644 (file)
@@ -1,9 +1,6 @@
 [submodule "jush"]
        path = externals/jush
        url = https://github.com/vrana/jush
-[submodule "JsShrink"]
-       path = externals/JsShrink
-       url = https://github.com/vrana/JsShrink
 [submodule "PhpShrink"]
        path = externals/PhpShrink
        url = https://github.com/vrana/PhpShrink
index 7b57f0a24e918d6961fa2f4b81f646ec6cbbbf87..ba46fd6141000ab2f2538e38f377e910358425b5 100755 (executable)
@@ -2,7 +2,6 @@
 <?php
 include __DIR__ . "/adminer/include/version.inc.php";
 include __DIR__ . "/adminer/include/errors.inc.php";
-include __DIR__ . "/externals/JsShrink/jsShrink.php";
 include __DIR__ . "/externals/PhpShrink/phpShrink.php";
 
 function add_apo_slashes($s) {
@@ -199,14 +198,12 @@ function minify_css($file) {
 }
 
 function minify_js($file) {
-       $file = preg_replace_callback("~'use strict';~", function ($match) { // keep only the first one
-               static $count = 0;
-               $count++;
-               return ($count == 1 ? $match[0] : '');
-       }, $file);
-       if (function_exists('jsShrink')) {
-               $file = jsShrink($file);
+       file_put_contents("compile.js", $file);
+       $terser = shell_exec("terser -c --comments false compile.js"); // prints warning to stderr if terser is not available
+       if ($terser) {
+               $file = $terser;
        }
+       unlink("compile.js");
        return lzw_compress($file);
 }