minify

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package minify implements a token-aware JavaScript minifier used to shrink the embedded runtime sources before they're served.

Scope (tier-2):

  • Strip line + block comments.
  • Collapse whitespace, preserving newlines only where ASI cares.
  • Distinguish regex literals from division.
  • Preserve string + template-literal payloads byte-for-byte.
  • Insert a single space when removing whitespace would fuse two adjacent tokens (`let a` → `leta`, `+ +` → `++`, `/ /` → `//`).

Out of scope (would be tier-3): identifier renaming, dead-code elimination, constant folding, anything that requires a parser.

The output is intentionally still valid, readable-ish JavaScript — it stays parseable by the browser without source maps and a developer can still set breakpoints inside it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Minify

func Minify(src string) string

Minify returns a shrunk-but-equivalent JavaScript source. The output preserves the semantics of the input across every construct the embedded runtime currently uses. Inputs that aren't valid JS produce undefined-but-stable output (the minifier never panics).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL