perf: minify web portal page JS and CSS (-23 KB flash) - #55
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before:
scripts/build_web.pyinlined each page's JS and CSS verbatim, becauseminify_htmldeliberately leaves<script>and<style>alone. The 218 KBfiles.jsshipped 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 pinnednpx --yes esbuild@0.24.2and falls back to anesbuildon PATH. esbuild does not rename top-level names in plain (non-module) scripts, so theonclick=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