jaspr icon indicating copy to clipboard operation
jaspr copied to clipboard

feat: Minify javascript in jaspr build step

Open walsha2 opened this issue 10 months ago • 0 comments

##Description

@schultek It looks like there is some considerable savings that can be made by simply minifying the resulting, compiled, JS files from dart2js. This would reduce the time taken to render an SSR app as this, rather large, un-minified JS is being sent by the server, namely app.client.dart.js

The following were generated using jaspr build (Jaspr CLI (Version 0.10.0)) for a relatively small app with just a couple screens.

Before Minification

968K	build/jaspr/web/main.clients.dart.js
468K	build/jaspr/web/main.clients.dart.js_1.part.js
1.4M	build/jaspr/web/components/app.client.dart.js

After Minification

584K	build/jaspr/web/main.clients.dart.js
292K	build/jaspr/web/main.clients.dart.js_1.part.js
852K	build/jaspr/web/components/app.client.dart.js

Additional Context

https://dart.dev/tools/webdev#build

I was under the assumption that webdev build and/or dart2js would minify the JS by default, no? Not sure why that is not happening here or if the option is not enabled.

packages/jaspr_cli/lib/src/commands/build_command.dart

Related

Maybe even something to minify the CSS? Although I understand if this should be an outside tool and up to the user.

walsha2 avatar Mar 26 '24 02:03 walsha2