简体   繁体   English

flutter web 交替/减小 canvaskit.wasm 的大小

[英]flutter web alternates/reduce size of canvaskit.wasm

My flutter web initial page load is slow(10-15 secs), Found that large amount of time is spent in downloading "https://unpkg.com/canvaskit-wasm@0.24.0/bin/canvaskit.wasm" which is around 2.5 MB as per browser logs.我的 flutter web 初始页面加载很慢(10-15 秒),发现下载“https://unpkg.com/canvaskit-wasm@0.24.0/bin/canvaskit.wasm”花费了大量时间根据浏览器日志,大约 2.5 MB。

Is there a way to reduce this time/alternate file path/ minification which can be done?有没有办法减少这个时间/替代文件路径/可以做到的缩小?

(package is built using flutter build web ) (使用flutter build web

For the moment there is no solution for this, anyways the Flutter team is working on that and there should be a solution as soon as possible.目前还没有解决方案,无论如何 Flutter 团队正在努力解决这个问题,应该尽快找到解决方案。 You can check the status of this in this link: Flutter github issue您可以在此链接中检查此状态: Flutter github issue

Changed web renderer to html renderer将 web 渲染器更改为html 渲染器

flutter build web --web-renderer html

which resulted in significant reduction in initial load time这导致初始加载时间显着减少

There is a possibility to integrate the canvaskit at build process and host it with your web app for offline support.可以在构建过程中集成 canvaskit 并将其与您的 web 应用程序一起托管以提供离线支持。

Therefore you need to define the url like:因此,您需要像这样定义 url :

flutter build web --dart-define=FLUTTER_WEB_CANVASKIT_URL=/canvaskit/

This may could also reduce loading time.这也可以减少加载时间。 (direct network connection, no dns lookup...) (直接网络连接,没有 dns 查找...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM