For a full comparison of minifiers, jump to https://methodfish.com/Articles/minifiers

PHPWee (adjusted to work with php8+)

This is a demonstration of the javascript minifier using PHPWee (adjusted to work with php8+) class

Input javascript:

Output:

/*!
 * This is an important comment
 * Date: 27-27
 */
var _var1=123;var _var2='abc';const _CONST1=1234;const _CONST2=9876;let _let1=123;let _let2=987;function getElemInfo(elem){var localvar1=123;var localvar2=345;let locallet1='abc';let locallet2='def';const localconst3=true;const localconst4=false;var test=locallet2.replace(/'/,'abc');var c=99;if(elem==false){return'NULL';}
if(elem==window){return'window';}
var newTx='';if(elem.tagName){newTx=newTx+' tag='+elem.tagName;}
if(elem.id){newTx=newTx+' id='+elem.id;}
if(elem.className){newTx=newTx+' class='+elem.className;}
if(localconst3)console.log('localconst3=true');else console.log('localconst3=false');if(1==2)console.log('1==2');else{console.log(`1<>2`);}
doSomething('Lorem Ipsum // Delor */');doSomething("Lorem \"Ipsum\" // Delor */");let myPet='seahorse';console.log('My favorite animal is the ${myPet};.');return newTx;}

Minify time: 0.0066 seconds; 886 bytes 66.07% of original size (from 1341 bytes).