bikehopper / bikehopper-ui

Friendly bike+transit directions (frontend)
Other
26 stars 1 forks source link

split out some big vendor modules into their own files #368

Closed Andykmcc closed 3 months ago

Andykmcc commented 3 months ago

this breaks our giant index.js into a few smaller files so they will be loaded in parallel. it should offer improved time to first paint because the data comes in faster while also improving out cache hit rate for these files because now turf and maplibre can be cached in a CDN and on device and will be reusable across deploys UI deploys so long as we dont change package versions. since we update these far less often than we update our own code this will basically halve the amount of data that needs to be downloaded for most page loads.

There is more that could be done on this front, such as bundling other stuff that changes infrequently into its own files, targeting 500kb per file, and pointing our react and maplibre to external CDN versions so we can get cache hit from other sites. but that introduces other complexity i dont think we need right now.

Andykmcc commented 3 months ago

sure, i just added a description. give it a read

Andykmcc commented 3 months ago

sadly gpx2fit isn't deferred here. the bytes will still be blocking main thread execution. i think to get to deferred loading automagically we need to enable dynamic-imports, which i plan to play with but my guess is it will be a whole can of worms

graue commented 3 months ago

pointing our react and maplibre to external CDN versions so we can get cache hit from other sites

That doesn't work anymore. https://gomakethings.com/cdn-caching-isnt-the-performance-boost-it-used-to-be/

Same-site caching of the libs might help sometimes, but probably not very much. I understand your hypothesis. I'm not convinced it's going to play out.

graue commented 3 months ago

Dynamic imports should work out of the box with Vite. We can also defer loading nivo until an itinerary is viewed.

Andykmcc commented 3 months ago

That doesn't work anymore. https://gomakethings.com/cdn-caching-isnt-the-performance-boost-it-used-to-be/

TIL This is something that has changes since i was in the frontend game

Andykmcc commented 3 months ago

The difference is negligible, on a clean cache page load. i don't see why we wouldn't do this since it is simple, done and will improve our cache hit rates, which is the biggest win we can get for initial launch of a deploy. I'll look into the other thing to deffer loading some stuff but i think that will be complicated and hurt TTFCP.

Before:

before

After

after