flutter web alternates/reduce size of canvaskit.wasm

Viewed 1749

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.

Is there a way to reduce this time/alternate file path/ minification which can be done?

(package is built using flutter build web)

3 Answers

Changed web renderer to html renderer

flutter build web --web-renderer html

which resulted in significant reduction in initial load time

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. You can check the status of this in this link: Flutter github issue

There is a possibility to integrate the canvaskit at build process and host it with your web app for offline support.

Therefore you need to define the url like:

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

This may could also reduce loading time. (direct network connection, no dns lookup...)

Related