Many Viewer package chunks contain a lot of optional features that are dynamically/lazily downloaded only when needed (audio, animation, shadows, webgpu, etc.). If you load a basic glTF using webgl, it’s currently around 535kb gzipped, well under 1mb (it is around ~2mb uncompressed, but gzip compression is basically ubiquitous at this point). You can test this out by simply downloading Babylon.js/packages/public/@babylonjs/viewer/test/apps/web/published.html at master · BabylonJS/Babylon.js, loading it in your browser locally, and looking at the network tab in chrome dev tools. For example:
Here you can see the top 5 chunks that make up most of the size. The first one is the main Viewer support, at 346kb. The next one is the default environment (which you can disable or replace with your own environment) which is 60kb. Next is the main glTF loader at 25kb (needed when the Viewer is loading a glTF file, but if you loaded a different file type a different chunk would be downloaded). Then the main support for PBR materials at ~18kb (unless you customize, all glTFs will have this, but other model types may not). Then finally the main AssetContainer support at ~7kb.
Also FYI, we have work planned to improve the side effects situation to make it much easier to use the main @babylonjs packages without unintentionally bringing in a lot of extra stuff. This should make it easier to get similar sizes as the Viewer without having to be extremely careful with your imports, and might help get sizes even smaller. We don’t quite have a timeline for this work yet, but we’ve done a fair bit of planning around it.
