8

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)

Gururaja Hegde
  • 323
  • 3
  • 9
  • I started an experimental polyfill of canvaskit that uses the browser APIs: https://github.com/wcandillon/canvaskit-lite. So far it looks promising. We test it with chrome and check that it produces the same images than the one made by CanvasKit. – wcandillon May 27 '23 at 16:24

3 Answers3

6

Changed web renderer to html renderer

flutter build web --web-renderer html

which resulted in significant reduction in initial load time

Gururaja Hegde
  • 323
  • 3
  • 9
4

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

Francesc Arolas
  • 325
  • 1
  • 12
2

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...)

Anneress
  • 171
  • 8