For minifying Javascript, CSS and/or HTML files to optimize and compress them so that loading or launching them become faster you can use various offline or online tools available.
If you already have NodeJS installed, you can simply install uglify-js and use it to minify any Javascript file:
npm i uglify-js -g
npx uglifyjs input.js -c -m -o output.js
This is the prefered method if you want to do a lot of minifying(i.e. because you are a developer or because you want to do a lot of customizations on your KaiOS device web apps).
As for online tools, just search for "javascript minifier"(Bonus: DuckDuckGo has a builtin one once you search this!)