Reduce compiled JS file size
See original GitHub issueAs it stands, our npm package index.js
is 218KiB (which is being compiled by the closure compiler here).
With the Echo example echo.proto, that has about 7 message types, 1 service, 3 unary methods and 5 streaming methods:
- The Closure example final
compiled.js
compiled by the Closure compiler: 317KiB - The CommonJS example final
dist/main.js
compiled bywebpack
: 415KiB - The same CommonJS example compiled by
browserify
: 479KiB - The CommonJS example with
.d.ts
typings generated, and then compiled bywebpack
: 499KiB
I tried babel-minify
and uglify-js
on some of these JS files and the output are not any particularly smaller.
There should be some other things we can do to further minimize the compiled JS code size.
Reference: #79
Issue Analytics
- State:
- Created 5 years ago
- Reactions:15
- Comments:30 (9 by maintainers)
Top Results From Across the Web
How to Optimize JavaScript Delivery to Speed Up Your Site
Compress JS. Server-side compression of text files can reduce file size substantially. This transferred JavaScript size allows more uncompressed data to ...
Read more >reduce the size of a js file - javascript - Stack Overflow
the js file on my site has a size of 1.5 MB . i am assuming it could be reduced. this file is...
Read more >5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
5 Methods to Reduce JavaScript Bundle Size · 1. Code Splitting with Webpack · 2. Using Webpack Plugins for Tree Shaking · 3....
Read more >Reducing JavaScript Bundle Size. Part One
js files to hundreds or thousands. If we were to request all of these individually, it would take an eternity! Instead, we use...
Read more >Optimizing JavaScript bundle size - DebugBear
It's easy to keep adding new packages and lose track of the size of your Webpack, Parcel, or Rollup bundle. But large JavaScript...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Did @jjbubudi’s fix ever end up being available? I’ve encountered the same issue — with a trivial
hello world
proto, the smallest my bundle got was 180~Kb with Webpack, of which, only 8Kb is actual application code. The rest appears to be grpc-web. This is a problem because our web app targets mobile devices, we simply don’t have the ability to add +180Kb to our payload, our landing page in total is smaller than that.I’ve also tried using Closure Compiler via Webpack, however, this predictably fails at
google-protobuf
on the advanced mode required to get the size reduction.Thanks for the hard work — it otherwise works very well. I would just love to be able to strip away the google-protobuf’s unused parts somehow, preferably with Webpack.
Good news guys! The changes for reducing bundle size of
google-protobuf
is merged, and the new version is out there 😍I am not sure do we need to update the version of this pkg to use the latest version of
google-protobuf
or not.Edit: I’ve opened this PR: https://github.com/grpc/grpc-web/pull/1291 to use the new version and fix this huge bundle size issue.