Open kbhalerao opened 4 days ago
Hi @kbhalerao,
Thanks for the kind words! I'm glad gdal3.js is working well in your SvelteKit project.
I’ve looked into dynamic linking and module splitting, but they aren’t really applicable for WebAssembly right now. Creating different builds with specific driver combinations is a good workaround.
Another option is compression. Both the .wasm and data files can be compressed and decompressed using DecompressionStream during initialization. This brings the total size down to around 11.3 MB (compressed .wasm is 9.2 MB, and data is 2.1 MB). Browsers and servers usually handle this automatically to reduce network traffic, but I could provide compressed versions on NPM/CDN to help with the file size limits.
Thank you for this wonderful project. I wanted to include this library in a SvelteKit project to be hosted on CloudFlare Pages, and to run the GDAL library as a Worker. The non-Worker version, using the CDN works fine as shown in the docs.
CloudFlare Pages has a limit of 25MB for uploaded assets.
To reduce the file size, I was able to successfully compile this package using the
-Oz
flag, as opposed to the current-O3
setting. This brings the compiled size for the.wasm
file from ~28MB to ~22MB, just under the CloudFlare limits, and it seems to work normally.I manually included the package files in my project's assets folder and linked them via the
paths
option ininitGdalJS()
Is there any way to host a smaller-sized variant of the package under this project on the CDN or in NPM, to make this directly usable for CloudFlare Pages users?
Is there another way to reduce file size by either splitting the large wasm file into multiple, or by configuring GDAL to include only a few common drivers?