Live data from Hacker News

Your single-page app is now a polyfill

itnext.io

21–30 of 164 posts

Re: Your single-page app is now a polyfill

#21
Maybe I am missing the point. When the problem is speed and the solutions seems single page app with bloated javascript or the thing the poster suggest.

Why isn't the solution just simple classical HTML without any bloated Javascript, which also needs to be executed. The CSS is cached, so it doesn't need to be reloaded and the next possible pages are prefetched via the correct META tags.

Re: Your single-page app is now a polyfill

#22
This is seriously nifty but you really don’t need SPAs or client-side request interception for page loads to feel “instant”. All you need is server-side rendering without a zillion third-party scripts. Clicking around Hacker News provides case in point.

Re: Your single-page app is now a polyfill

#23
post #14

> it all started with the desire to eliminate blank screens in between pages and reduce payload sizes Hell, no. The "two main reasons" for single page app given at the beginning (faster app, reduced network traffic) are actually not the main one. The main one is that the browser loses its state at each page reload, and that the state on the server, if any, needs to be reconciled every time with that on the browser. I…

I think those are definitely some key advantages to SPAs, but my impression when they started becoming adopted, especially to the consumers (users) was one seamless thing with no new pages etc.. certainly development is more manageable with client only state, but I don't see that as the first big sell.

Re: Your single-page app is now a polyfill

#24
post #14

> it all started with the desire to eliminate blank screens in between pages and reduce payload sizes Hell, no. The "two main reasons" for single page app given at the beginning (faster app, reduced network traffic) are actually not the main one. The main one is that the browser loses its state at each page reload, and that the state on the server, if any, needs to be reconciled every time with that on the browser. I…

> it all started with the desire to eliminate blank screens in between pages and reduce payload sizes

That isn't even a thing anymore, except in SPA's or Internet Explorer; Chrome (seems to?) wait until some content is loaded before it switches to the clicked page, there is no blank screen.

Payload sizes is not really a problem either given that content is not that much data. Images and media take up the brunt of bandwidth; the payload size is not the issue.

Re: Your single-page app is now a polyfill

#25

I feel like the whole article misses the point. Yes, the rendering delay caused by a non-streaming HTML parser exists, but unless you screw things up elsewhere, that's going to be less than 1ms of delay. Yes, bloated frameworks are annoying, but not due to their computational overhead per se, but because they increase download size and because Javascript is slower then native code in general. I find it very telling t…

> 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/ ). 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

Yeah, I did the same with 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.

Re: Your single-page app is now a polyfill

#26
> Why do we build single-page apps?...

> We want our web apps to feel “instant”...

> Blank screens make for a bad user-experience...

In my experience if you really need fast page loads, SPAs are off the table. So the premise of the article makes no sense to me. In fact, what do people on HN think the main reason to choose an SPA is these days?

Re: Your single-page app is now a polyfill

#27
post #16

Earlier quoted context omitted.

There are many use cases for service workers you probably haven't heard of. For example at my last job (at a YC startup) we built a service worker that used P2P to serve mp4 video over WebRTC. It was the correct place to interop with the download - it was explicit and it would have been impossible without it. ---- I think the common use case (of much control over caching) is also quite reasonable. I agree the API and…

"it would have been impossible without it" C++ desktop app It'll even have 2x the throughput at the same CPU level. Plus users can choose when they want to run your app, as opposed to you accidentally draining their battery because they left an old tab open. Boom, possible and better :p

Better = higher barrier to entry?

Re: Your single-page app is now a polyfill

#28
post #26

> Why do we build single-page apps?... > We want our web apps to feel “instant”... > Blank screens make for a bad user-experience... In my experience if you really need fast page loads, SPAs are off the table. So the premise of the article makes no sense to me. In fact, what do people on HN think the main reason to choose an SPA is these days?

For me, SPA is either chosen due to "fancy factor" or because the app is too complex to easily implement as a traditional (SSR) web page. That could be a complex search+filter with autocomplete, or a social network-like UI with infinite scroll and dynamic widgets.

Re: Your single-page app is now a polyfill

#29
post #11

Please. Please don't do this. Service workers cause so many problems, I have never seen an implementation that didn't completely explode at some time or another, and as far as I can tell the only fix is to open the dev tools and delete service workers. They're a bad solution to a non-problem.

Twitter's implementation just exploded on me the other day on my phone. Since then I cannot open ANY links to twitter anymore. I just get a page from the browser that says "Cannot complete request".

It's on my phone so I can't just clear a single site's data, and I cannot be bothered to clear everything and relog everywhere.

Re: Your single-page app is now a polyfill

#30

With service workers disabled on firefox the site just breaks, no graceful degradation/progressive enhancement. When clicking links in the header the url will change, but the page content doesn't.

The trouble is trailing slashes and inconsistent behaviour between the service worker and the web server. https://instantmultipageapp.com/images/ loads from the server, and not the service worker. Observe how it lacks the Blog link in the header, which is missing in what the server is rendering—see /images/index.html in the repository. https://instantmultipageapp.com/images loads from the service worker, and the serv…

This is just one bug you found. There are more edge cases for sure, serviceworkers intercepting requests and caching is a nightmare.
Post reply on HN