Code Compression

Minification strips what the browser does not need: comments, whitespace, optional tags, long local names. Online minifier pages suit a one-off file; production sites minify in the build, on every deploy. Vite 25,978 (Build Tools and Bundlers) minifies production builds by default, using Oxc 616,256 for JavaScript and Lightning CSS for CSS. For a plain static site, three open-source command-line tools do the job:

Minifying JavaScript, CSS and HTML from the command lineShell
npm install --save-dev terser lightningcss-cli html-minifier-terser
npx terser src/app.js --compress --mangle --toplevel -o dist/app.js
npx lightningcss --minify src/style.css -o dist/style.css
npx html-minifier-terser --collapse-whitespace --remove-comments --remove-optional-tags \
  src/index.html -o dist/index.html

Given a 159-byte app.js that defines addTax(price, rate = 0.08) and logs addTax(19.99), Terser 9,344 inlines the single-use function, renames its parameters and drops the comment, leaving 66 bytes that still print 21.59:

Output of 67
console.log(function(o,n=.08){return(o*(1+n)).toFixed(2)}(19.99));
Open-source minifiers
Tool Minifies Licence
Terser (https://github.com/terser/terser 9,344 ) JavaScript BSD-2-Clause
esbuild 126 (https://github.com/evanw/esbuild 40,071 ) (Go) JavaScript, CSS MIT
Lightning CSS (https://github.com/parcel-bundler/lightningcss 7,691 ) (Rust) CSS MPL-2.0
html-minifier-terser 481 (https://github.com/terser/html-minifier-terser 481 ) HTML MIT

Minified code is not protection: the DevTools { } pretty-print button reformats it instantly. Generate source maps (--source-map) so your own stack traces stay readable.