3 ms·
> Ship your users an app including a copy of the data ahead of time I did exactly that with a hobby project (https://www.acceleratul.ro/ https://www.acceleratu
by gabipurcaru 6y ago
> Ship your users an app including a copy of the data ahead of time
I did exactly that with a hobby project (https://www.acceleratul.ro/ https://www.acceleratul.ro/). The funny thing is that I had to add a short (~50ms) artificial delay with a spinner before showing search results, because people completely missed the fact that the page had refreshed
- modeless 6y agoYeah, I did the same with https://james.darpinian.com/decoder/ https://james.darpinian.com/decoder/. It's an underused technique for sure. It's enraging when I have to repeatedly wait multiple seconds to load a bloated results page containing 10 additional rows from a database query (e.g. paginated product listings) when I could have easily downloaded the complete query results or even the entire database in less time.
- tartoran 6y agoNice helpful project, I think I may have used it once while in Romania. Yeah, for small static data it absolutely makes sense to embed it in the app itself. But imagine your app was world wide or it needed to account for dynamic data, not sure it would make sense to ship a few dozen MBs all at once.
- victor106 6y agoThis is cool. What techniques did you use to include a copy of the data?
- gabipurcaru 6y agoit's just a bunch of JSON bundled inside the rest of the JS assets with webpack
- nexuist 6y agoI believe this entire technique is known as SSR - Server-Side Rendering. It's built in to Vue and React and you can find examples on their respective sites.
- asddubs 6y agothat's confusing, I've only ever heard SSR/server side rendering to mean actually rendering html and serving that, as opposed to SPAs
- nexuist 6y agoWell, the idea is that you render the first pass of the SPA and serve that HTML to the client. Rather than just injecting the data into the SPA source code, you inject the data and render the page, and then serve that page. Then whatever changes the user makes to the page after that initial load gets handled by the SPA. This way the user avoids having to wait for the SPA and all its dependencies to load before the page can even appear, and the developer doesn't have to differentiate between what happens on the client side and server side (remember using PHP to inject variables into JS source code?) because they can just bake it into their SPA.
- asddubs 6y agothat's pretty neat, I didn't know that react could do that. Shame no one ever seems to make use of it
- dr-detroit 6y agoBecause neat doesn't pay the bills. Why would I pay to dedicate computing resources to something that anyone's computer or phone can do in under 3 seconds which has scientifically been proven to be an acceptable wait time between click(tap) and render?