Efficiently compile node material for asset size

Node Materials allows a quick and simple way of customizable shaders without writing in glsl itself, but the size of serialized json is large.
Since asset size it important for web, can it be compiled to more size-efficient form?
In Node Material Editor, there are Save, Generate code, and Export shaders, which of them is considered more size efficient? The output of Export shaders are likely the smallest, would the full code size be smaller or larger than the other two?
Is there something like terser that can minify shaders?

The code from “Export shaders” is not usable “as is”, you would need to do a bit (and potentially a lot of) additional work to make it work in a shader. It’s there for illustration purpose only, essentially.

The .json export is bigger than the code export, but once zipped, they are quite similar: 5.33kb for the code export (51kb uncompressed) vs 5.66kb for the .json export (139kb uncompressed). Also, it would be possible to reduce the size of the original .json file by removing the formatting (spaces / CRLF) + removing the data used by the NME only.

1 Like