Optimize build performance: disable dev minification, add content-hash caching, increase debounce #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Development builds were taking 13-18 seconds per reload due to unnecessary minification, no caching, and full Tailwind regeneration on every change.
Changes
Disable minification in development
get-document-component.tsx: Setminify: falsein esbuild configContent-hash based build caching
Increase hot reload debounce
setup-hot-reloading.ts: 150ms → 500msPerformance Impact
Tailwind CSS processing (3-5s) automatically optimized via build caching.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
fonts.googleapis.com/usr/local/bin/node node /home/REDACTED/work/htmldocs/htmldocs/packages/htmldocs/node_modules/.bin/../next/dist/bin/next build(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Problem
Users report that both initial render and hot reload are extremely slow, taking 13-18 seconds even for very basic templates with just a few divs and text.
Example console output:
This occurs:
<Document><div><p>Hello</p></div></Document>)This makes the development experience very poor and frustrating for users.
Root Cause Analysis
After investigating the code, we identified several performance bottlenecks in
packages/htmldocs/src/utils/get-document-component.tsx:🔴 Issue #1: Minification in Development Mode
Lines 37-41:
Impact: Minification is unnecessary during development and adds several seconds to each build. It should only run in production builds.
🔴 Issue #2: Full Tailwind CSS Processing on Every Build
Lines 50-54:
Impact: On every hot reload, Tailwind CSS:
tailwind.config.jsThis adds 3-5 seconds per build.
🔴 Issue #3: No Build Caching
Every file change triggers a complete rebuild from scratch:
Impact: Even if a file hasn't changed, it's rebuilt completely.
🔴 Issue #4: Hot Reload Debounce Too Aggressive
File:
packages/htmldocs/src/cli/utils/preview/hot-reloading/setup-hot-reloading.tsLine 52:Impact: 150ms is too short - multiple rapid saves can trigger overlapping reloads.
Solution
Implement the following optimizations:
✅ Fix #1: Disable Minification in Development
File:
packages/htmldocs/src/utils/get-document-component.tsxChange:
Expected improvement: 16s → ~8-10s
✅ Fix #2: Optimize Tailwind CSS Processing
Option A (Recommended): Implement CSS caching - only regenerate CSS when
.cssfiles ortailwind.config.jschangeOption B: Use Tailwind's JIT mode more efficiently by extracting CSS generation to a separate process
Expected improvement: 8-10s → ~4-6s
✅ Fix #3: Implement Build Result Caching
Add intelligent caching based on file content hash:
Expected improvement: Subsequent saves of unchanged files: ~100ms
✅ Fix #4: Increase Hot Reload Debounce
File:
packages/htmldocs/src/cli/utils/preview/hot-reloading/setup-hot-reloading.tsChange:
Expected improvement: Prevents overlapping reloads, more stable hot reload
Expected Performance After Optimizations
Current Performance:
Target Performance:
Implementation Priority
High Priority (Quick Wins):
Medium Priority:
Testing
After implementing these changes, verify with: