Skip to main content

A Note About File Size

At a first glance, the file size of this library might look huge. NPM reports it's size to be almost 50MB, which is extremely large if you're planning to build browser-focused applications. The good news is: The amount of data that is actually shipped to your users is only a small fraction of that amount.

TL;DR

The total amount of (compressed) data shipped to your users is around 9.1MB for the full version of OpenCascadee.js. It can be significantly less if you're creating a custom build.

Which assets will be shipped to your users?

This is a list of the main assets of the NPM package, both in terms of file size and functionality. The sizes of the other assets are insignificant.

SizeFile
9.2MBdist/opencascade.full.d.ts
330.2kBdist/opencascade.full.js
48.9MBdist/opencascade.full.wasm

The asset named dist/opencascade.full.d.ts is a file containing type definitions, meant to simplify the development process and enabling auto-completion on most code editors. This file is not shipped to your users.

Both dist/opencascade.full.js and dist/opencascade.full.wasm are files generated by Emscripten and contain the core logic of the library. The JavaScript file is already compressed (i.e. minified) and the entire file size must therefore be shipped to your users.

The largest asset is obviously the WASM file. However, an important aspect of WASM files is that they can be compressed extremely well with commonly used compression algorithms like gzip and brotli. Using brotli compression, the amount of data that actually gets shipped to your users is (measured via the ocjs.org - website) "only" 9.1MB, i.e. ~20% of the uncompressed size of the WASM file. These compression algorithms are enabled out of the box without configuration with most hosting providers and browsers.

What does that mean for loading times?

Downloading 9MB on a good 3G connection would take around 9 seconds. On a 4G connection or a modern DSL connection, it should takes less than a second.

What if that's still too much?

Especially on slow network connections, this file size might be too large. Another important aspect is the significant amount of resources and time it takes to compile and optimize the WASM file for your user's target architecture. This process might take longer than downloading the WASM asset itself.

The examples on this website are using a custom build

A custom build of OpenCascade.js is powering all examples on this website. It has a combined JS+WASM size of 7.1MB (compressed 2.4MB). Check out the custom build definition.

If you want to support such use-cases, first have a look at the App-Development Workflow documentation and then read the guide on how to create custom builds, which can be significantly smaller and faster to load than the (developer-focused) official NPM package.

Disabling exceptions greatly reduces file size

For many applications, exception support is not required in OpenCascade.js and can be disabled. For a full build, this reduces the file size by ~45% and greatly improves performance (even if exceptions are never thrown). Pass -sDISABLE_EXCEPTION_CATCHING=1 in the emccFlags of your custom build to disable exceptions. Check out this custom build definition for an example.