r/lua • u/Clear_Inevitable_718 • Jul 15 '25
Good lua minifier with options
What I'm looking for:
- A minifier. Optional obfuscation doesn't hurt, but it is not something I care about
- Option to ignore renaming certain variables/globals, e.g. callbacks.
- I'm very character constrained, so 'simple' minifying is not enough
- Optimally I can run it locally.
Would love any pointers or suggestions! I only found two possible candidates but neither was usable:
- https://github.com/mathiasbynens/luamin - doesn't seem to have any way to not rename specific variables/globals
- https://github.com/stravant/lua-minify - has a global rename ignore list, but it didn't seem to use it? couldn't get it not to rename certain globals on my machine
Edit:
I should have given you helpful folks more information. I'm writing lua code that will be run by an application. I'm allowed to give 8096 characters of code, and no more, which is why I want to minify. I have no control over the application beyond being able to give it 8096 characters of lua code.
2
u/eee170 Dec 30 '25
I am having an extremely similar problem, if you found a good minifier, please let me know.
1
u/redtonpupy Jul 15 '25
I hope I understand what you mean…
Vscode is great for that:
I hope it helps!
1
u/EvilBadMadRetarded Jul 15 '25
May google "lua squish", it is a tool with minifying as one of the function. 'uglify' may be what you want, as it said further minimizing the size of a minified output.
1
u/drcforbin Jul 16 '25
Why not just save the lua bytecode rather than the lua?
1
u/[deleted] Jul 15 '25
I think you can do it yourself, its really easy (lol) take a look at my fmt, specifically you want to look at the codeline section which spits out the smallest code, sadly, I never got to renaming variables in a permutative manner but you can do it yourself, and given that you are choosing to ignore the renaming, its better if you yourself control the entire loop.
Using lxsh you can do the heavy lifting on the whole parsing aspect as you can see, if you've written 8k characters of luacode then I'm sure you can do this via just looking at the code (don't ask me, I'm done with coding though)
0
u/[deleted] Jul 15 '25
[deleted] — view deleted comment