dwyl / app

Clear your mind. Organise your life. Ignore distractions. Focus on what matters.
http://dwyl.github.io/app/
147 stars 22 forks source link

[PR] Flutter web speed up patch #330

Closed LuchoTurtle closed 1 year ago

LuchoTurtle commented 1 year ago

pertains to #326

This PR will attempt to speed up loading the Flutter web.

LuchoTurtle commented 1 year ago

When running sudo sh ./patch_web.sh on the built bundle and then running python3 -m http.server 8000 to serve it locally...

image

No errors of files not found or anything.

Was having issues with registering the service worker before but it was due to the patch files not being correctly formatted.

LuchoTurtle commented 1 year ago

Will need to temporarily deploy this to fly.io to check if there are any differences to the metrics but I doubt it will make any difference, as the generated .js is essentially the same.

nelsonic commented 1 year ago

Fly.io deployment pipeline should still be setup: https://dwylapp.fly.dev/

LuchoTurtle commented 1 year ago

It is but it's only deployed when the PR is merged into the main branch -> https://github.com/dwyl/app/blob/e3a455413847cd3f85b2024a433751e38a70c56b/.github/workflows/ci.yml#L48

Will temporarily disable the line just to check.

LuchoTurtle commented 1 year ago

Running https://dwylapp.fly.dev/ in https://pagespeed.web.dev/ yields the following results.

image
nelsonic commented 1 year ago

@LuchoTurtle note: this was already all 100 because of the landing page with the button that loads the flutter.js ... This is the "before" picture: https://github.com/dwyl/app/issues/326#issuecomment-1455596679

The real test is if we remove the landing/loading page completely what score do we get. 💭

LuchoTurtle commented 1 year ago

Removing the loading page

https://pagespeed.web.dev/analysis/https-dwylapp-fly-dev/igq79mp1ci?form_factor=mobile

image

:/

LuchoTurtle commented 1 year ago

Seems like the outage broke my PR. I'm pushing to the branch but commits like 8573667697c88f728430fabeaed2136f786b4195 are not being associated

LuchoTurtle commented 1 year ago

They're working now.

LuchoTurtle commented 1 year ago

Landing page without button

https://pagespeed.web.dev/analysis/https-dwylapp-fly-dev/tehee9qm3q?form_factor=mobile

The results are a bit better...

image
LuchoTurtle commented 1 year ago

Invisible button with display:none or visibility:hidden

https://pagespeed.web.dev/analysis/https-dwylapp-fly-dev/y4zst563yo?form_factor=mobile

image

Doesn't seem to do this any justice either...

LuchoTurtle commented 1 year ago

Going to compare the network effects with landing page with concurrent download that was implemented.

LuchoTurtle commented 1 year ago

Without the speed patch...

Screenshot 2023-03-27 at 17 41 33

With the speed patch...

Screenshot 2023-03-27 at 17 50 36

Checked these numbers several times in incognito windows and there's a consistent +- 200ms difference. Even though it doesn't allow us to remove the loading screen and maintain our 100% metrics, it's still a noticeable difference to load up.

LuchoTurtle commented 1 year ago

@nelsonic assigning over to you. Up to you if you want to keep this or not, even if it doesn't fix the original issue https://github.com/dwyl/app/issues/326. I feel like https://github.com/dwyl/app/issues/326 (when it comes to metrics) has been resolved by adding the landing page. The metrics all hit 100%.

If this gets merged, I'll add the section to https://github.com/dwyl/learn-flutter

milan-ciganovic commented 1 year ago

Does this work with flutter stable branch?

LuchoTurtle commented 1 year ago

@milan-ciganovic It should, yes. Here's a guide if you want a more detailed walkthrough -> https://github.com/dwyl/learn-flutter/tree/main/guides/flutter-web-speed-boost.

This will save you a few milliseconds when loading the Flutter web app but you should test how this "patch" fares in your application and how much time it "saves" 😃