getkirby / getkirby.com

Source code and content for the Kirby website
https://getkirby.com
131 stars 266 forks source link

Home: improve delay when switching story images #2322

Closed distantnative closed 4 months ago

distantnative commented 4 months ago
lukasbestle commented 4 months ago

About preloading: I don't think it makes sense to preload all playground stories when visiting the homepage, but we could make it a bit faster by preloading the main story image immediately in the switchTo method when a new story is loaded.

Could work like this:

  1. Add a custom data-image attribute to the link in the menu.
  2. Before starting the fetch request for the HTML, do a new Image().src = url; to preload the image in the background.
distantnative commented 4 months ago

@lukasbestle I am also thinking if there would be a better way than fetch the whole home page when switching, just to extract the playground part. Maybe we could work with a content representation here that only return the playground part?

lukasbestle commented 4 months ago

Made some additional enhancements to reduce flickering. I think we could merge it like this already, check the results in production and optimize further if needed. I feel like reducing the HTML payload would bring us a tiny improvement compared to the added complexity as it's just text and normal pages load quickly.

distantnative commented 4 months ago

I still experience sometimes the flicker. But it's the same on the old version. So still purely improvement. I agree on merging already and tweaking further later.