# Wasm output size problem

**URL:** <https://ziggit.dev/t/wasm-output-size-problem/17887>\
**Category:** Explain\
**Tags:** standard-library\
**Created:** [October 8, 2026, 4:18am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887 "2026-10-08T04:18:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [October 8, 2026, 4:18am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/1 "2026-10-08T04:18:08Z")

</div>

Zig 0.17 increases one my wasm lib size from 71k to 81k (about the same as 0.14), whereas 0.15 and 0.16 each shrinked it about 5k.

So far not bad. I’m just curious the reasons. I guess it is a balance between percentages of code generation and (non-generated) runtime code in the std lib.

---

<div class="post-metadata">

**Author:** ![hemisputnik](https://ziggit.dev/user_avatar/ziggit.dev/hemisputnik/32/9625_2.png) [@hemisputnik](https://ziggit.dev/u/hemisputnik)\
**Post date:** [October 8, 2026, 5:29am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/2 "2026-10-08T05:29:26Z")

</div>

Get ready, it’s probably gonna increase a lot more… At least in debug mode, that is.

[#37032 - default to self-hosted wasm in debug mode](https://codeberg.org/ziglang/zig/issues/37032)

---

<div class="post-metadata">

**Author:** ![Nae](https://ziggit.dev/user_avatar/ziggit.dev/nae/32/10157_2.png) [@Nae](https://ziggit.dev/u/Nae)\
**Post date:** [October 8, 2026, 5:34am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/3 "2026-10-08T05:34:29Z")

</div>

did you check the difference? e.g.

```zig
wasm-opt --func-metrics --print-function-map

```

To get those kind of size, I guess you already had the `.strip = true` Module.CreateOption, did it change in 0.17?

---

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [October 8, 2026, 7:01am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/4 "2026-10-08T07:01:59Z")

</div>

Ah, it seems the 81k is the debug size (built with `zig build wasm`), with the `-Doptimize=ReleaseSmall` option, the size is 68k.

It is strange. in `build.zig`, I have set the `.optimize` of the wasm module as `.small`. I don’t understand why `-Doptimize=ReleaseSmall` is still needed on the `zig build` command line.

```zig
    const wasmTarget = b.resolveTargetQuery(.{
        .cpu_arch = .wasm32,
        .os_tag = .freestanding,
    });
    const wasmOptimize: std.lang.Optimize = .small;

    const wasmLibModule = b.addModule("tmd-wasm", .{
        .root_source_file = b.path("library/tmd-wasm/wasm.zig"),
        .target = wasmTarget,
        .optimize = wasmOptimize,
    });

```

---

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [October 8, 2026, 7:13am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/5 "2026-10-08T07:13:25Z")

</div>

The `wasmLibModule` depends on some other modules:

```zig
    wasmLibModule.addImport("tmd", tmdLibModule);
    wasmLibModule.addImport("list", listLibModule);
    wasmLibModule.addImport("tree", treeLibModule);

```

Do the dependency modules inherit the `.optimize` option of the `wasmLibModule` module? Do I need to create small-optimize versions for the dependency modules, to avoid using the `-Doptimize=ReleaseSmall` option in the `zig build wasm` command?

---

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [October 8, 2026, 8:30am UTC](https://ziggit.dev/t/wasm-output-size-problem/17887/6 "2026-10-08T08:30:38Z")

</div>

> [@zigo](#):
>
> Do the dependency modules inherit the `.optimize` option of the `wasmLibModule` module? Do I need to create small-optimize versions for the dependency modules, to avoid using the `-Doptimize=ReleaseSmall` option in the `zig build wasm` command?

My mistake. Without specifying the `.optimize` option, dependency modules do inherit the `.optimize` option of the `wasmLibModule` module:

```zig
    const tmdLibModule = b.addModule("tmd", .{
        .root_source_file = b.path("library/tmd-core/tmd.zig"),
        //.target = target,
        //.optimize = optimize,
    });

```
