{"id":13896645,"url":"https://github.com/jirutka/luasrcdiet","last_synced_at":"2025-10-27T10:39:04.744Z","repository":{"id":22055437,"uuid":"94270160","full_name":"jirutka/luasrcdiet","owner":"jirutka","description":"Compresses Lua source code by removing unnecessary characters (updated fork of http://luasrcdiet.luaforge.net/)","archived":false,"fork":false,"pushed_at":"2022-02-02T00:46:39.000Z","size":555,"stargazers_count":84,"open_issues_count":7,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-02T08:32:18.681Z","etag":null,"topics":["lua","minification"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jirutka.png","metadata":{"files":{"readme":"README.adoc","changelog":"CHANGELOG.adoc","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-14T00:19:32.000Z","updated_at":"2025-01-05T15:13:54.000Z","dependencies_parsed_at":"2022-07-27T03:00:08.928Z","dependency_job_id":null,"html_url":"https://github.com/jirutka/luasrcdiet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluasrcdiet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluasrcdiet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluasrcdiet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fluasrcdiet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirutka","download_url":"https://codeload.github.com/jirutka/luasrcdiet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238968307,"owners_count":19560586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","minification"],"created_at":"2024-08-06T18:03:03.550Z","updated_at":"2025-10-27T10:39:04.656Z","avatar_url":"https://github.com/jirutka.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"= LuaSrcDiet\n:toc: macro\n:toc-title:\n:proj-name: luasrcdiet\n:gh-name: jirutka/{proj-name}\n:gh-branch: master\n:ldoc-url: https://jirutka.github.io/{proj-name}/ldoc/\n\nifdef::env-github[]\nimage:https://travis-ci.org/{gh-name}.svg?branch={gh-branch}[\"Build Status\", link=\"https://travis-ci.org/{gh-name}\"]\nimage:https://img.shields.io/badge/ldoc-docs-blue.svg[\"LDoc\", link=\"{ldoc-url}\"]\nendif::env-github[]\n\n\nCompresses Lua source code by removing unnecessary characters.\n\nThis is revival of LuaSrcDiet originally written by mailto:keinhong@gmail.com[Kein-Hong Man].\n\n\n[discrete]\n== Table of Contents\n\ntoc::[]\n\n\n== Introduction\n\nLuaSrcDiet is a utility written in Lua for the purpose of turning Lua 5.1+ source code like this:\n\n[source, lua]\n----\nlocal function calc_indent(s)\n  local col = 0\n  for i = 1, #s do\n    local c = sub(s, i, i)\n    col = col + 1\n    if c == \"\\t\" then  -- tab\n      while col % 8 \u003e 0 do col = col + 1 end\n    end\n  end--for\n  return math.floor(col / 8)\nend\n----\n\ninto a more compact or “squeezed” form (minus a lot of unnecessary characters) like this:\n\n[source, lua]\n----\nlocal function _(l)local e=0\nfor o=1,#l do\nlocal n=n(l,o,o)e=e+1\nif n==\"\\t\"then\nwhile e%8\u003e0 do e=e+1 end\nend\nend\nreturn r.floor(e/8)end\n----\n\nand still be able to run normally under standard Lua 5.1+ or LuaJIT 2.0+.\n\nLuaSrcDiet reduces the size of https://www.lua.org/[Lua] 5.1+ source files by aggressively removing all unnecessary whitespace and comments, optimizing constant tokens, and renaming local variables to shorter names.\nFor example, LuaSrcDiet squeezes its own sources from 156 kiB down to 42 kiB.\nFurther bzip2 or lzma compression can bring the file size further down to under 13 kiB.\nThat’s _12×_ reduction in size, if you don’t mind the decompression and compilation time.\n\nLuaSrcDiet is broadly similar to Luiz’s http://www.tecgraf.puc-rio.br/%7Elhf/ftp/lua/5.1/lstrip.tar.gz[lstrip] (tar.gz) for Lua 5.1, which can be found on Luiz’s http://www.tecgraf.puc-rio.br/%7Elhf/ftp/lua/[Libraries and tools for Lua] page.\nLuaSrcDiet with its modified Lua source code lexer and parser allows most optimization options to be enabled or disabled separately, and can do a bit more like renaming local variable names.\n\nThere is also Matthew Wild’s http://matthewwild.co.uk/projects/squish/home[squish], which incorporates LuaSrcDiet and offers more code compression options.\nSquish goes beyond what LuaSrcDiet does, as the latter (as a matter of policy) only sticks to source code readable by standard Lua binaries.\n\n\n== LuaSrcDiet and Obfuscation\n\nOwing to the use of LuaSrcDiet among certain things like WoW add-ons, the following is a clarification of this author’s intentions:\n\n* LuaSrcDiet can be used as a _weak_ obfuscator.\n  However, note that the structure and arrangement of the source code stays exactly the same, so _do not_ depend on such a weak form of obfuscation if you really needed heavy-duty obfuscation.\n* LuaSrcDiet was written for the purpose of comparing minimum-sized sources with binary chunks, their compressibility, and the parsing performance of the Lua interpreter.\n  I don’t care one iota about obfuscation, it’s compression I’m interested in.\n* This is _experimental software_.\n  If you want to use it for important stuff, be sure to apply source and binary equivalence checking.\n  I’m not, of course, responsible for anything you do.\n* Treat it like a text filter tool or a compiler.\n  There is no legal requirement to acknowledge LuaSrcDiet or to place its copyright notice anywhere for the source code you processed.\n  Your app is stuff _you_ wrote, LuaSrcDiet is stuff _I_ wrote.\n  Simples.\n* Obfuscation cannot be defined precisely so we are dealing with subjective judgements.\n  I think it’s fair if people want to apply a mild deterrent against casual plagiarism.\n  Those desperate for original sources should instead turn their energies towards Open Source or Free Software.\n\n\n== Changes in This Fork\n\n* Code-base updated to be compatible with Lua 5.1–5.3.\n* Added support for processing Lua 5.2–5.3 code (except binary equivalence checking).\n* Published on https://luarocks.org/[LuaRocks] (the Lua package manager).\n* Documentation comments converted to https://github.com/stevedonovan/LDoc[LDoc’s] format (except lparser.lua).\n* Documentation wiki pages converted to AsciiDoc.\n\n\n== Installation\n\nNote: If you want to bootstrap development environment for running tests, read the next section.\n\n\n=== Using LuaRocks\n\nYou can install {proj-name} using https://luarocks.org[LuaRocks] (the Lua package manager):\n\n[source, subs=\"+attributes\"]\nluarocks install {proj-name}\n\nor to get the latest development version:\n\n[source, subs=\"+attributes\"]\nluarocks install --server=http://luarocks.org/dev {proj-name}\n\n\n== Set Up Development Environment\n\n. Clone this repository:\n[source, subs=\"+attributes\"]\ngit clone https://github.com/{gh-name}.git\ncd {proj-name}\n\n. Source file `.envrc` into your shell (or manually add `$(pwd)/.venv/bin` to your `PATH`):\n[source]\nsource .envrc\n\n. Install Lua and modules for running tests into directory `.venv`:\n[source]\n./script/bootstrap\n\n. Start hacking!\n\n. Run linters and tests:\n[source]\n./script/test\n\n\n== Documentation\n\n* \u003c\u003cdoc/features-and-usage#, Features and Usage\u003e\u003e\n* \u003c\u003cdoc/performance-stats#, Performance Statistics\u003e\u003e\n* \u003c\u003cdoc/tech-notes#, Technical Notes\u003e\u003e\n\n\n== Acknowledgements\n\n* The original author of LuaSrcDiet and its documentation is mailto:keinhong@gmail.com[Kein-Hong Man].\n  History of this repository until 2012 has been recreated from https://code.google.com/archive/p/luasrcdiet/downloads[release tarballs] hosted on Google Code.\n* Parts of LuaSrcDiet is based on http://yueliang.luaforge.net/[Yueliang], which is in turn based on the https://www.lua.org/[Lua] sources.\n\n\n== License\n\nThis project is licensed under http://opensource.org/licenses/MIT/[MIT License].\nFor the full text of the license, see the link:COPYRIGHT[COPYRIGHT] file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fluasrcdiet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirutka%2Fluasrcdiet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fluasrcdiet/lists"}