Skip to content

perf: minify web portal page JS and CSS (-23 KB flash) - #55

Merged
prokrypt merged 1 commit into
developmentfrom
claude/project-thread-v7jlsy
Sep 27, 2026
Merged

prokrypt merged 1 commit into
developmentfrom
claude/project-thread-v7jlsy

Conversation

@prokrypt

Copy link
Copy Markdown
Owner

Before: scripts/build_web.py inlined each page's JS and CSS verbatim, because minify_html deliberately leaves <script> and <style> alone. The 218 KB files.js shipped with all its comments and indentation, and gzipped FilesPageHtml was 62,543 B. x4-pro-light-sleep firmware was 5,558,336 B (84.8% of app0).

After: page JS and CSS go through esbuild before gzip. FilesPageHtml drops to 41,410 B gz and the firmware to 5,535,152 B (84.5%), which saves 23,184 B. The Files page also loads 21 KB less over Wi-Fi.

How: one esbuild run minifies all web/pages/*.{js,css}. It uses a pinned npx --yes esbuild@0.24.2 and falls back to an esbuild on PATH. esbuild does not rename top-level names in plain (non-module) scripts, so the onclick= and other inline handlers keep working. If Node is not installed, the script prints a notice and builds with the unminified sources as before, so the firmware stays buildable everywhere. GitHub's Ubuntu runners ship Node, so CI and release builds get the minified pages.

Checked: I loaded all four generated pages in headless Chromium. No page errors, and every inline on* handler resolves to a defined function (38 handlers). I also rebuilt without Node to confirm the fallback path.

Hardware check (any device, web portal): open Home, Files, Settings and Fonts. On Files, upload a file, create and delete a folder, open the image preview, and run an EPUB conversion. Settings should load and save.

🤖 Generated with Claude Code

https://claude.ai/code/session_013k1W4UZTzyPQnTVXwZUbkS


Generated by Claude Code

build_web.py inlined web/pages/<slug>.js and .css verbatim (minify_html
preserves <script> and <style>), so the 218 KB files.js shipped with all
comments and indentation. Page assets now go through one pinned esbuild
run (npx esbuild@0.24.2, or esbuild on PATH) before gzip. esbuild keeps
top-level names in plain scripts, so inline on* handlers still resolve.
Without Node the script prints a notice and ships the sources unminified.

x4-pro-light-sleep: 5,558,336 -> 5,535,152 B (-23,184 B).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013k1W4UZTzyPQnTVXwZUbkS
@prokrypt
prokrypt merged commit d3b4d29 into development Sep 27, 2026
9 checks passed
@prokrypt
prokrypt deleted the claude/project-thread-v7jlsy branch September 27, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants