-
Notifications
You must be signed in to change notification settings - Fork 15
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 the JavaScript Bundle Size of MapTiler SDK (Currently 1.1 MB) #160
Comments
Looking at the composition analysis at https://bundlephobia.com/package/@maptiler/sdk@3.0.1 it can be seen that 80% of the bundle size comes from maplibre-gl, so there's not much that we could do on the maptiler-sdk level. It would definitely be beneficial to implement tree shaking of the whole library and it's already being discussed in maplibre: maplibre/maplibre-gl-js#977 As for the CDN builds of MapTiler SDK, we provide the minified versions of the library with CloudFlare CDN in front handling the transit compression, so people using that are actually getting a brotli/gzip compressed version. |
From version 2.3.0 to 3.0.1, the library grew by 230KB. I think we can take steps to improve it. |
Looking more into this, there seems to be +110 kB jump between v2.3.0 and v2.4.0 (comparing the But I cannot find anything that would explain the size increase in the changelog: v2.3.0...v2.4.0 Anybody interested in digging deeper? |
Maybe because of -> import { validateStyleMin } from "@maplibre/maplibre-gl-style-spec"; link |
The current size of the MapTiler SDK JavaScript library is approximately 1.1 MB, which is relatively large and impacts the loading performance of web applications, especially on slower networks or resource-constrained devices. Reducing the library size will significantly improve usability and adoption for developers.
Proposed Solutions:
1. Tree-Shaking & Modularization:
• Break the library into smaller modules or sub-packages so that developers can import only the features they need. For example:
import { Map } from 'maptiler-sdk/core';
import { Marker } from 'maptiler-sdk/marker';
Why is This Important?
Reducing the size of the SDK will:
• Improve page load times.
• Reduce bandwidth usage for end-users.
• Enhance performance on mobile devices with limited resources.
• Align with best practices for modern web development.
Additional Context:
Please let us know if there are any existing plans or ongoing work to reduce the library size. If possible, we’d love to contribute or test any experimental builds to support this effort.
Thank you for your work on the MapTiler SDK and for considering this enhancement! Let me know if you need more details or benchmarks.
The text was updated successfully, but these errors were encountered: