fastn icon indicating copy to clipboard operation
fastn copied to clipboard

light mode images are loading in dark mode as well

Open amitu opened this issue 2 years ago • 0 comments

Issue

When I am loading a fastn powered website in dark mode, it first loads all light mode images (because fastn serves pages with light mode always, and on frontend we switch to dark mode).

Possible Solution

For dynamic mode, when site is deployed via fastn serve, we should store a cookie, dark-mode, true or false, and on server render in the right mode if cookie is present.

This will prevent browser from seeing the light mode SSR.

Steps to Reproduce (for bugs)

Go to fastn.com, and switch to dark mode, and view the network tab. You will see a lot of <image-name>.png and <image-name>-dark.png both, when only later should have loaded.

Context

I was debugging the performance, when deploy on Heroku. Right now Heroku version is 10-20x worse than Vercel deployed one, and a lot of time is going in images, so reducing images can improve performance.

Your Environment

  • fastn Version (I.e, output of fastn -v): 0.4.1
  • Operating System: Mac
  • Web Browser: Safari

amitu avatar Nov 14 '23 06:11 amitu