openimsdk / openim-electron-demo

Instant Messaging web desktop
https://openim.io
Apache License 2.0
143 stars 168 forks source link

How to compress the size of wasm files? #51

Closed sxw1995 closed 1 week ago

sxw1995 commented 5 months ago

What would you like to share?

The wasm file is too large and the user experience is not very good. How can i achieve compression?

Additional information

View the packaged dist directory

sxw1995 commented 5 months ago

Thank you for openim Professional help and i Solved this problem。use nginx to achieve the goal。 nginx conf as this: gzip on;

需要压缩的常见静态资源

gzip_types text/plain application/javascript   application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/wasm;
#由于 nginx 的压缩发生在浏览器端,而微软的 ie6 有坑,会导致压缩后图片看不见,所以这个选项是禁止 ie6 下开启压缩;
gzip_disable "MSIE [1-6]\.";
#如果文件大于 1k 就启动压缩;
gzip_min_length 1k;
#以16k为单位,按照原始数据的大小以4倍的方式申请内存空间,一般此项不需要修改;
gzip_buffers 4 16k;
#压缩的等级,数字选择范围是 1-9,数字越小压缩的速度越快,但消耗 cpu 就越大;
gzip_comp_level 1;