{# canonical_base is the OWNING tenant's origin: all 16 Peasy domains serve the same catalogue, so a page rendered by a non-owner points its canonical at the owner instead of competing with it. Falls back to this site for static/self-owned pages. #}
🍋
Menu
Web

Minification

Code Minification

The process of removing unnecessary characters from code (whitespace, comments) to reduce file size.

Technical Detail

Code minification removes whitespace, comments, shortens variable names (in JS), and applies optimizations like dead code elimination. JavaScript minifiers (Terser, esbuild) can reduce file size by 40-70%. CSS minifiers merge duplicate rules, shorten color values (#ffffff → #fff), and remove redundant units (0px → 0). Combined with Brotli compression, minified assets achieve total size reductions of 80-90%. Source maps (.map files) enable debugging minified code by mapping back to original sources.

Example

```javascript
// Simple CSS minifier
function minifyCSS(css) {
  return css
    .replace(/\/\*[\s\S]*?\*\//g, '')  // remove comments
    .replace(/\s+/g, ' ')                // collapse whitespace
    .replace(/\s*([{};:,])\s*/g, '$1')   // remove around symbols
    .trim();
}
// 1024 bytes → 612 bytes (40% reduction)
```

Related Tools

Related Terms