Optimization¶
The optimize.py script runs after sphinx-build to minify and
compress the output for production deployment.
Usage¶
python build.py docs-prod # build + optimize in one step
# or:
make docs-prod
# standalone:
python optimize.py _build/html
What It Does¶
Minifies HTML — removes comments, collapses whitespace (preserves
<pre>contents). Useshtmlminif installed, otherwise a built-in regex processor.Minifies CSS — strips comments and whitespace. Uses
rcssminif installed, otherwise built-in.Minifies JS — removes single-line comments, collapses blank lines.
Pre-compresses to .gz — creates gzipped copies at level 9 for
nginx gzip_staticor similar CDN features.Reports savings — total bytes saved across all files.
Example Output¶
● Optimizing _build/html/…
Minified: 42 files
385,200 → 298,400 bytes (22.5% reduction)
Gzipped: 56 files (87,300 bytes saved)
Total saved: 174,100 bytes
✓ Optimization complete
Pre-compiled CSS¶
The theme can ship with a pre-compiled theme.css. If you don’t
modify SASS, you can skip make css and deploy using the shipped
CSS. This means CI only needs Sphinx — no dart-sass required.
Tip
After modifying SASS, commit the updated theme.css so CI and
other developers don’t need SASS tooling.