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.

[Feature Request] Reduce bundle size + dependencies?

See original GitHub issue

Is your feature request related to a problem? Please describe.

Building RS throws bundle size warnings. Looking at the vendor bundle, there are a few packages that can definitely be replaced. The two standouts to me are react-helmet and axios. Both have much smaller alternatives.

For react-helmet, react-head would save 4.5k after compression. https://bundlephobia.com/result?p=react-helmet@6.0.0 https://bundlephobia.com/result?p=react-head@3.3.0

And for axios, isomorphic-unfetch would save 4k after compression. https://bundlephobia.com/result?p=axios@0.19.2 https://bundlephobia.com/result?p=isomorphic-unfetch@3.0.0

There are other to look into. For instance, history v5 looks like it will be much smaller. Something to keep an eye on. The intersection observer polyfill is also really big. It might be worth considering producing that functionality some other way.

Describe the solution you’d like

I’d like to see the vendor bundle reduced down to the bare essentials.

Describe alternatives you’ve considered

The deps all look critical to RS functionality, so this is the only solution I see.

Additional context

I am open to submitting PRs, if you’re open to merging them! 😁

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mikestopcontinuescommented, Apr 27, 2020

Axios: Unless axios itself switches to fetch, I don’t see them being able to cut too much code. I took a look a year or so ago, and nothing stood out. While I think a fetch polyfill would be the best call, there’s also redaxios, which preserves the axios api, but uses fetch under the hood. However, it adds almost 1k zipped on top of the polyfill to preserve all the transformers and stuff.

React-Helmet: Do you mean not-bundled in the export code? That’s good to know, though one of my use cases requires bundling once, and exporting multiple times in serverless, so I would still be interested in pulling it out. On the topic, why no out-of-the-box export bundle-analyzer? Have I simply missed it?

IntersectionObserver: What does it get used for other than prefetch visibility? For that, a hook/handler leveraging one window.onScroll that does the math for each element (with scrollY, viewport height, etc) would totally replace the need.

In any case, thanks for getting back so quickly. I’m eager to hear what you think.

1reaction
docrinehartcommented, Jan 1, 2021

FWIW (as I’m trying to use RR v6) I think it’s worth calling out.

Reach Router and it’s sibling project React Router are merging as React Router v6. In other words, Reach Router v2 and React Router v6 are the same. ~ https://reach.tech/router/

That said, it does look like I’ll need to dig into react-static-plugin-react-router and look at updating it locally. Maybe if I find time to do so, I can submit a PR…

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Slimming down your bundle size - LogRocket Blog
A critical part for improving frontend performance is to reduce the JavaScript bundle size that should be downloaded via the network.
Read more >
Possible ways to reduce your webpack bundle size - Medium
It removes lodash features you don't use. This will significantly reduce your bundle size. How do I do this? Install the dependency from...
Read more >
Small Bundles, Fast Pages: What To Do With Too Much ...
This post will explain why bundle size matters and recommend tools and ... visualise, and most importantly, shrink your JS bundles.
Read more >
Minimizing Webpack bundle size - Anvil
Learn how to minimize your Webpack bundle size by following these best practices, ensuring an optimal user experience.
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 Reddit Thread

No results found

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