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

Bundle Size, Leaflet integration and more ... #59

Closed
ChrisGitIt opened this issue Jan 21, 2021 · 5 comments
Closed

Bundle Size, Leaflet integration and more ... #59

ChrisGitIt opened this issue Jan 21, 2021 · 5 comments

Comments

@ChrisGitIt
Copy link

Hi everbody!

Nice to see an effort for an open web!

I don't want to disturb the ongoing efforts for this project, but i had my problems with the original MapBoxGLJs implementation and I wonder what the community thinks about the following suggestions:

1: Leaflet Integration
I like leaflet.js and tried several times to integrate MapBox Tiles into leaflet (tried several plugins), but was not successful.
Why leaflet? Leaflet seems to be active in development and its looks like there are several "reinvention of the wheel" concerning features. Most important (for me), the bundled and gzipped size seems A LOT smaller. Last time I checked: 40 KB vs 220 KB!

2: Bundled size:
I also tried to figure out why leaflet is so much smaller than MapBoxGLJs, but due to the sheer size of MapBoxGLJS, I never had enough time to truly compare both libs. I guess, its just the different programming approach. MapBoxGLJS seems to be overengineered. Or does the webgl stuff take so much size?

3: EcmaScript "import":
I was always wondering why using the "import" is not done according to specs in so many libs and instead relying on a bundler in order to get a lib working. I know why "bundling" is currently common in web development, but http2 and the upcoming http3 makes bundling almost always superfluous and installing more than 20 Megabyte of "Bundler" Software in order to "bundle" seems more than wasteful. I don't want to start bragging about this nonsense and arising problems (like the latest webpack version broke many bundling pipelines.).
To put this in a nutshell: It should (and actually IS) possible to "Just download the source" and use a simple <script src> to integrate the lib. You know, just like jQuery in the old times.

Any feedback and discussion is greatly appreciated!

Greets, Chris

@mourner
Copy link
Contributor

mourner commented Jan 22, 2021

the bundled and gzipped size seems A LOT smaller. Last time I checked: 40 KB vs 220 KB!
I guess, its just the different programming approach. MapBoxGLJS seems to be overengineered. Or does the webgl stuff take so much size?

The short answer to this is that good map rendering (drawing the raw data as neat polygons, lines, labels, patterns, icons, with nice transitions as you zoom and pan etc.) is a very hard problem. Leaflet doesn't have to deal with this at all because it relies on loading map tile images that already have everything rendered on the server. GL JS on the other hand loads raw data and implements all the rendering logic. If you compare its code to some server-side rendering projects like mapnik, it's actually astonishing how small GL JS is given the difficulty of the task it solves. Years of engineering thought have been put to keep it this small.

If you don't need the advantages of client-side vector rendering technology, Leaflet is a much better fit because it's small and simple. If you do need vector rendering, you'll have to deal with a relatively big bundle size — there's no way around it. Disclaimer: I'm the author of Leaflet.

@msbarry
Copy link
Contributor

msbarry commented Jan 22, 2021

+1 to what @mourner said - I added bundle size reporting to CI (example output) to keep a downward pressure on bundle size long term and prevent accidental increases by changing a build config or something. Here's where the space currently goes if you are interested:
image
Total size is off a bit because it adds up gzipped sizes but it gives you a rough idea.

Also, FWIW vector tiles in densely populated areas can start to exceed 200kb gzipped.

@Jonibigoud
Copy link

tried several times to integrate MapBox Tiles into leaflet (tried several plugins), but was not successful.

Actually, you can integrate vector tiles from Mapbox (or Maptiler, or your own vector tileserver ) in leaflet with the help of "mapbox-gl-leaflet" plugin: https://github.com/mapbox/mapbox-gl-leaflet

@wipfli
Copy link
Member

wipfli commented May 2, 2021

MapLibre has a repo now for leaflet bindings: https://github.com/maplibre/maplibre-gl-leaflet

@HarelM
Copy link
Member

HarelM commented Jun 30, 2021

I'm not sure if there's anything to do here...
Please let me know if there's something to address here, otherwise please close the issue.
I've used leaflet in the past, it a great piece of software, but modern vector tiles is a whole different league... :-)

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

6 participants