Help us shape the future of Go! Take the 2026 Go Developer Survey

htmlcompact

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package htmlcompact shrinks serialized HTML syntax without touching text, comments or raw content, and proves every result by comparing parsed trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	BeforeBytes int    `json:"beforeBytes"`
	AfterBytes  int    `json:"afterBytes"`
	SavedBytes  int    `json:"savedBytes"`
	Skipped     string `json:"skipped,omitempty"`
}

Result reports what compaction did. Skipped explains why the input was kept.

func Compact

func Compact(raw []byte) ([]byte, Result)

Compact syntax, never text. Even indentation can become visible through CSS white-space, copied text, inline layout or later script changes. The general minify/html KeepWhitespace option still collapses it and changes DOM values. Reuse the existing lexer and attribute escaper, without those transformations. Comments, raw text and closing/document tags pass verbatim. Attribute names/case and namespaces are never normalized here.

Jump to

Keyboard shortcuts

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