Skip to content

Large file size with fetch example? #1078

Closed
@liamcurry

Description

@liamcurry

Compiling the fetch example here: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/fetch

Generates a larger .wasm file than expected at 155KB, which can be reduced to 115KB with wasm-opt.

I've copied the source to my own project and compiled with these commands:

cargo build --target wasm32-unknown-unknown --release
wasm-bindgen target/wasm32-unknown-unknown/release/fetch.wasm --out-dir dist
wasm-opt -Oz --output dist/fetch_bg_opt.wasm dist/fetch_bg.wasm
$ ls -lah dist
total 449K
drwxr-xr-x 1 sagan 197121    0 Dec  2 12:11 ./
drwxr-xr-x 1 sagan 197121    0 Dec  2 12:11 ../
-rw-r--r-- 1 sagan 197121   50 Dec  2 12:23 fetch.d.ts
-rw-r--r-- 1 sagan 197121 9.3K Dec  2 12:23 fetch.js
-rw-r--r-- 1 sagan 197121 155K Dec  2 12:23 fetch_bg.wasm
-rw-r--r-- 1 sagan 197121 115K Dec  2 12:25 fetch_bg_opt.wasm

I have this in my Cargo.toml file:

[profile.release]
lto = true
opt-level = "s"
debug = false
panic = "abort"

Is there any way to shrink this file down? 100KB is kind of a lot for just fetching/deserializing some JSON.

Metadata

Metadata

Assignees

No one assigned

    Labels

    file-sizeIssues related to compiled wasm file sizes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions