Gzipped model using gltf-transform not loading

Good Day,

I am trying to lower my GLB model size using gzip compression. I created the gzip file using gltf-transform toolkit.

When I load the gzip file, I get a progress leading to 100%, But after its downloaded, I get an error “Unexpected token in JSON at position 0”

Please let me know how one can load the gzip file. I think the GLTF loader is not able to decompress it.

Note : My project is based on Vanilla js, So I won’t be able to use Node packages.


The error likely means that the web server you’re using doesn’t correctly serve the file with gzip HTTP headers. GLTFLoader does not decompress gzip – it’s the responsibility of the web browser itself (e.g. Chrome) to do that, and this only happens if the correct HTTP headers are set by the server.

1 Like

So If I correct the header issue, The Browser decompressing and the GLTF Loader loading the model, All this will happen automatically, Am I right?

If the file is served with the correct gzip HTTP headers, the browser will decompress it automatically and GLTFLoader will receive the same data to load as if the model had not been compressed.

Right understood, Thanks