question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce compiled JS file size

See original GitHub issue

As 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 by webpack: 415KiB
  • The same CommonJS example compiled by browserify: 479KiB
  • The CommonJS example with .d.ts typings generated, and then compiled by webpack: 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:open
  • Created 5 years ago
  • Reactions:15
  • Comments:30 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
nehbitcommented, Apr 4, 2019

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.

4reactions
sayjeyhicommented, Oct 8, 2022
Screen Shot 1401-07-16 at 12 01 21

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found