memos
memos copied to clipboard
Gomark wasm file is excessively large
Describe the bug
My memo's version is v0.19.1. Recently, I have noticed that the loading time is extremely long. The largest file I have identified is: /assets/gomark-Nm4xOTNx.wasm, which is 8.5MB. However, in the live demo, the same file is only 1.9MB.
What can I do to reduce the size of this file? Thank you.
Steps to reproduce
Load any page in memos
The version of Memos you're using
0.19.1
Screenshots or additional context
No response
For a web App, loading every page needs to download a file that is *MB in size, it will extremely slow down its performance. I have already rollbacked my instance to v1.19.0, and look forward to the improvement.
@boojack It's possible to reduce gomark size a little bit by building it with -trimpath -ldflags="-s -w".
The current gomark build has about 8.293,59 KiB;
-trimpath:8.280,98 KiB. This removes local build system paths references, such/home/user/src/memos/related_file.goand panic stack traces will show justgithub.com/usememos/memos/related_file.go-ldflags="-s -w":8.023,07 KiB. This removes debug information and debug tables.-trimpath -ldflags="-s -w"8.010,43 KiB
This will save ~283 KiB. It's not much, but it's easily achievable.
Other possible solutions:
- https://tinygo.org
- https://github.com/WebAssembly/binaryen
By running wasm-opt gomark.wasm -o gomark-slim.wasm -Oz --enable-bulk-memory, its possible to reduce gomark to 7.120,39 KiB.
Gzip/deflate it's currently disabled in Echo, but users can enable compression using a proxy.
Quick solution for users
On Caddy, adding this directive under Memos entry will enable compression:
encode {
zstd
gzip
minimum_length 1024
}
For nginx:
gzip on;
gzip_min_length 1024;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml application/wasm application/octet-stream;
Serving gomark as it is using gzip will result in a total ~2.1 MiB transferred.
For a web App, loading every page needs to download a file that is *MB in size, it will extremely slow down its performance. I have already rollbacked my instance to v1.19.0, and look forward to the improvement.
The plug-in is transferred only once, at first page load. Your browser keeps it in cache.
Use a proxy with compression enabled to improve network performance. Check my previous comment.
Add "application/wasm" to reverse proxy is useful, thanks.
This issue is stale because it has been open 14 days with no activity.
Please fix it as soon as possible!
Reference to: https://github.com/yourselfhosted/gomark-wasm/issues/1