# LilScript makes JavaScript libraries smaller

https://yeargun.github.io/lilscript/ LilScript is a typed, compression-first language that compiles into js and sometimes into exec(will be more stable in future). The compiler mangles, reshapes the program into optimized js that happens to be 5-15% smaller (after gzip/br compression or raw) compar…

- **Page:** https://magpie.gallery/i/lilscript-makes-javascript-libraries-smaller-fdky
- **Type:** Link to an idea elsewhere
- **Category:** AI & dev
- **Runs on:** web
- **Tags:** compiler, javascript, minification, bundle-size, typed-language

## Source

Web · yeargun: LilScript makes JavaScript libraries smaller

- **Original:** https://news.ycombinator.com/item?id=49374554

> https://yeargun.github.io/lilscript/ LilScript is a typed, compression-first language that compiles into js and sometimes into exec(will be more stable in future). The compiler mangles, reshapes the program into optimized js that happens to be 5-15% smaller (after gzip/br compression or raw) compared to the best performing JS toolchains like oxc/esbuild/terser/.. ## What has been proven to work with LilScript? - makes VSCode's core js modules 20% smaller on average - makes the world's most performant & small markdown rendering npm library, marked, 5-7% smaller and 10% faster - and many more demos.. works with pretty much any js/ts library ## How it is compressing js finer than vite/oxc/terser/esbuild/.. ### 1. By changing the app. ``` class Vector { float x; float y; init(float x, float y) { this.x = x; this.y = y; } float lengthSquared() { return this.x * this.x + this.y * this.y; } } int[] values = [1, 2, 3, 4]; auto doubled = values.map((int value) => value * 2); int sum = 0; for (int i = 0; i < doubled.length; i++) { sum += doubled[i]; } Vector vector = new Vector(3.0, 4.0); if (vector.lengthSquared() == 25.0) { print(`sum=${sum}`); } ``` Above code compiles into this: ``` var b=[1,2,3,4].map(a=>a2|0); var a=0,c=0; while(a<b.length){ c=c+b[a]|0; a=a+1|0; } console.log(`sum=${c}`) ``` This is not minification of the same program. The compiler changed the app. oxc / esbuild / terser / .. starts from JS and mostly keeps the shape of the app. Meanwhile LilScript the language is designed from scratch to give compiler any extra knowledge that could help the compiler's compilation. Just like Google Closure Compiler - Advanced Mode, and beyond. ### 2. Tryhard property mangling. Visit the world's most used web applications, chatgpt.com, and read the source codes. You will see that, there are lots of framework related js properties that dont get minified, and are indeed human readable. Those names stay in the bundle because the toolchain cannot prove they are local. A pro

## Rules for reuse

- Build your own version: don't copy another product's code, look, icons, colours or copy.
- The original belongs to its author; Magpie only links to it.
- The original content's copyright belongs to its creator. Magpie doesn't download or re-upload it; we only show the link and the official preview.
