Game Over

Nitro in Web Assembly - Performance

Here’s some rough insight into what happens when you run a Nitro app entirely in-browser.

Without Wasm

Nitro requires 717kB of dependencies in the browser, regardless of whether you’re using Wasm or not (717kB gzip / 3.3MB raw):

FileSize
styles.css7.5kB
main.css1.5KB
main.js3.2MB
loading.gif18.1kB
[font].woff233.5kB
[font].css1.3kB
favicon.ico15.4kB
Total3.3MB

Once the above dependencies are loaded, application startup is near-instantaneous.

Adding Wasm

The same app on Wasm requires an additional 8.15MB (8.15MB gzip / 18.19MB raw):

FileSize (gzip / raw)
nitride.js1.8kB / 5.4kB
h2o_nitro-[…].whl12.8kB / 12.8kB
pyodide.js14.8kB / 46.0kB
packages.json5.5kB / 28.0kB
pyodide_py.tar103kB / 103kB
pyodide.asm.js322kB / 2MB
pyodide.asm.data3.4MB / 5.4MB
pyodide.asm.wasm3.2MB / 9.5MB
distutils.tar984kB / 984kB
micropip-[…].whl16.8kB / 16.8kB
pyparsing-[…].whl98.8kB / 98.8kB
packaging-[…].whl41.4kB / 41.4kB
Total8.15MB / 18.19MB

Of these, Nitro’s dependencies are negligible (~14kB).

Downloading and initializing the above dependencies adds 3-5 seconds of overhead. YMMV depending on network, CPU and browser.

Overall, not bad, but the overhead is noticeable.

That said, notice that Nitro runs unmodified in browsers. The same ~13kB h2o-nitro wheel from PyPI runs as is, with an additional 1.8kB for nitride.js, the application runtime atop Pyodide.