Just an general q:
Why did babylon.js grow to 7217KB and if there is a possibility to shrink it?
We are looking for the slickest possible version, so we wonder to make it smaller, somehow?
Best. Werner
Just an general q:
Why did babylon.js grow to 7217KB and if there is a possibility to shrink it?
We are looking for the slickest possible version, so we wonder to make it smaller, somehow?
Best. Werner
Babylon.js ships with shaders for both WebGL and WebGPU
We tried something similar, to exclude the webgpu with minor success atm.
Might be a way to go..
Yeah we can get bjs to slim down to a few kbs if you only use a portion of it.
Would that be the ES6 treeshaking method?
Actually I need to give our programmer a hint
yes totally. es6 can strip away a lot
that’s why our viewer is less than a MB for instance
Hm…
All the @babylonjs/viewer/dist/chunks/*.min.js
sum up to 4.2Mb, though.
Currently I’m working on my own viewer with blackjack and hookers cherry-picked features,
and it makes 2.7Mb (with 2.1M being Babylon chunk).
How do you get less than 1Mb?
Cc @ryantrem
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.