Stripping comments from a 500 KB JavaScript bundle without breaking inline onclick handlers
A widget shipped as a single hand-concatenated JavaScript file grew to about 500 KB, exposing internal notes, fix logs, and TODOs to anyone viewing the source. Standard minifiers rename global functions, which would break the inline onclick attributes the page relies on. The author instead uses esbuild with whitespace minification and legal-comment removal, which leaves identifiers intact. The build script adds syntax and handler-existence checks and falls back to the unminified file if the tool is unavailable. The approach is not obfuscation and does not replace a proper bundler, but it suits a small single-file widget.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in