# Treeshaking ShaderWGSL

**URL:** <https://forum.babylonjs.com/t/treeshaking-shaderwgsl/59598>\
**Category:** Questions\
**Tags:** treeshaking\
**Created:** [July 17, 2025, 12:35pm UTC](https://forum.babylonjs.com/t/treeshaking-shaderwgsl/59598 "2025-07-17T12:35:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![link2twenty](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/link2twenty/32/19199_2.png) [@link2twenty](https://forum.babylonjs.com/u/link2twenty)\
**Post date:** [July 17, 2025, 12:35pm UTC](https://forum.babylonjs.com/t/treeshaking-shaderwgsl/59598/1 "2025-07-17T12:35:50Z")

</div>

I’m on a bit of treeshaking journey trying to get my bundle size down currently BabylonJS is sitting just over 2000kB (not compressed).

While investigating I noticed that materials (pbrBaseMaterial and StandardMaterial in my specific case) load in Shaders and ShadersWGSL, as I’m not using WebGPU I imagine ShadersWGSL will be loaded and never touched? Is there anything I can do to shake this out?

> dist/static/babylon.js 2,018.82 kB │ gzip: 462.55 kB  
> dist/static/loaders.js 80.09 kB │ gzip: 19.78 kB

 ![Bundle Visualizer](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/1/91c5f45b7d63dc7ae391995a580fafbda2ccccd2.png)

I appreciate Babylon is a super complex bit of code and will be quite large regardless but I’m just seeing what I can shave off 😅

Thanks for all your hard work ❤

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [July 17, 2025, 2:31pm UTC](https://forum.babylonjs.com/t/treeshaking-shaderwgsl/59598/2 "2025-07-17T14:31:27Z")

</div>

cc @ryantrem

---

<div class="post-metadata">

**Author:** ![ryantrem](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ryantrem/32/34010_2.png) [@ryantrem](https://forum.babylonjs.com/u/ryantrem)\
**Post date:** [July 17, 2025, 4:10pm UTC](https://forum.babylonjs.com/t/treeshaking-shaderwgsl/59598/3 "2025-07-17T16:10:45Z")

</div>

In various places we do dynamic imports of either glsl or wgsl shaders, depending on what engine is being used. If you aren’t configuring your bundler to do code splitting / chunking, then all these dynamically imported dependencies will end up in your bundle. I think the only thing you can do in that case is add additional bundler configuration to explicitly exclude certain sources.
