Skip to content

Use terser for minification - #3

Open
thomastay wants to merge 2 commits into
masterfrom
use-terser
Open

Use terser for minification#3
thomastay wants to merge 2 commits into
masterfrom
use-terser

Conversation

@thomastay

@thomastay thomastay commented Mar 3, 2022

Copy link
Copy Markdown
Owner

Currently just running it on esbuild's already minified output.
Not sure if this is the best approach, may change to different bundle strategy.

Saves 150b gzipped, 500b minified. Quite significant, terser really is a work of art.

However, this adds about 500 or so ms to incremental build time. Before this, build time was ~200ms, now it is ~700ms, which is approaching the threshold of 1s.

Edit: found some more terser options which changes 120b saved -> 150 bytes saved

Comment thread build.ninja
@@ -1,4 +1,4 @@
wordleOut = ..\\..\\..\\Documents\\website\\wordle-helper\\index.html
wordleOut = dist/index.html

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to change this back

@thomastay thomastay changed the title Use terser on esbuild's output Use terser for minification Mar 3, 2022
@thomastay

Copy link
Copy Markdown
Owner Author

Consider: making terser configurable in tools/configure.js

@thomastay

thomastay commented Mar 5, 2022

Copy link
Copy Markdown
Owner Author

image

Here's a trace of the tasks that have to run from a nearly clean build, assuming that bin/build.exe is already built (if not it dominates the timing diagram)

As you can see, the time taken by terser is quite significant, and adds about 600ms in this run.

Here is the trace without terser:
image

Basically, there is about 450 - 500ms unavoidable wait before index.html can be built, since we have to wait for the SSR content to be built.

However, terser can be really slow, and even accounting for that, can still add an additional 500-600ms to the build.

Not sure if this is the best approach, may change to different bundle
strategy.
Reduce by another 40 bytes
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.

1 participant