Consider adding gzip or brotli compression for Draco and Basis WASM binaries

I noticed in a recent project that the Draco and Basis Universal WASM libraries are served by default from the https://preview.babylonjs.com domain. For example:

Given the term “preview” appears in the domain … is it considered acceptable to use those defaults for production applications, or would that be discouraged? If that usage is OK, it’d be a helpful bundle size improvement if these resources could be compressed by default (gzip, brotli). With some static hosting providers that’s a simple setting to enable, with others it might be more complex. In the case of the Basis transcoder that’s a 450kb → 220kb improvement. Thanks!

EDIT: Perhaps a partial answer to my own question here, the Basis and Draco libraries do change over time, so I suppose an unversioned URL is not the greatest idea for production use. If there’s a versioned alternative to the URLs above I’d be interested to know – and in that case the same Gzip/Brotli question would apply.

1 Like

Seems that for production version there are

1 Like

Thanks – these versions are gzipped so that looks much better!

1 Like

Ended up with this configuration —

import { KhronosTextureContainer2 } from "@babylonjs/core/Misc/khronosTextureContainer2";
import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression";

// Production CDN uses gzip, while the default 'preview' CDN does not.
DracoCompression.Configuration.decoder.wasmUrl = "https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js";
DracoCompression.Configuration.decoder.wasmBinaryUrl = "https://cdn.babylonjs.com/draco_decoder_gltf.wasm";
DracoCompression.Configuration.decoder.fallbackUrl = "https://cdn.babylonjs.com/draco_decoder_gltf.js";

KhronosTextureContainer2.URLConfig.jsDecoderModule = "https://cdn.babylonjs.com/babylon.ktx2Decoder.js";
KhronosTextureContainer2.URLConfig.jsMSCTranscoder = "https://cdn.babylonjs.com/ktx2Transcoders/msc_basis_transcoder.js" as any;
KhronosTextureContainer2.URLConfig.wasmMSCTranscoder = "https://cdn.babylonjs.com/ktx2Transcoders/msc_basis_transcoder.wasm" as any;

2 Likes

Hey Don!

Yes we consider the preview as our current version. But you already found the cdn version which is great for your needs

So all good :wink:

1 Like

I added application/wasm to the list of files being compressed on our preview CDN. it should propagate soon. Might be after the next full purge (i.e. next nightly)

4 Likes