Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce bundle size #125

Open
Loykos opened this issue Jul 18, 2018 · 2 comments
Open

Reduce bundle size #125

Loykos opened this issue Jul 18, 2018 · 2 comments

Comments

@Loykos
Copy link

Loykos commented Jul 18, 2018

Hi,

I like very much this library! I'm building the library with webpack and the result file weight ~600 kb. Is there a way to reduce the bundle size?

Thanks for your suggestions

@Wildhoney
Copy link
Owner

Wildhoney commented Jul 18, 2018

We've already externalised clipper-lib, leaflet and ramda

Majority of the bundle is taken up by jsts (~430kb) which is a dependency of turf-intersect which we use for determining polygon intersections.

I don't think externalising turf-intersect makes much sense, as it's a fairly niche dependency. Requiring it to be an external dependency only defers the issue since the eventual bundle size remains the same.

When gzipped bundle size is ~127kb which of course you should be applying server-side. I actually think that's a fairly healthy size for the complexity of FreeDraw.

It may also be worth considering dynamically importing FreeDraw, and displaying a loading message of some kind whilst the chunk is loaded:

async loadMap(textNode) {
  textNode.innerHTML = 'We are loading the map...';
  await import('./map-with-freedraw.js');
  // voila...
}

That way FreeDraw stays out of the your main bundle, and is only requested when actually needed.

@Loykos
Copy link
Author

Loykos commented Jul 18, 2018

Thanks @Wildhoney for answering me. I currently have gzip compression. I'll load the module async with dynamic import and I'll keep following the project.

Thank you!

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

No branches or pull requests

2 participants